| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright 2015 gRPC authors. |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H |
| 20 |
#define GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H |
| 21 |
|
| 22 |
#include <string> |
| 23 |
#include <vector> |
| 24 |
|
| 25 |
#include <grpc/grpc_security.h> |
| 26 |
#include <grpcpp/security/auth_context.h> |
| 27 |
#include <grpcpp/support/string_ref.h> |
| 28 |
|
| 29 |
#include "src/core/lib/gprpp/ref_counted_ptr.h" |
| 30 |
#include "src/core/lib/security/context/security_context.h" |
| 31 |
|
| 32 |
namespace grpc { |
| 33 |
|
| 34 |
class SecureAuthContext final : public AuthContext { |
| 35 |
public: |
| 36 |
explicit SecureAuthContext(grpc_auth_context* ctx) |
| 37 |
: ctx_(ctx != nullptr ? ctx->Ref() : nullptr) {} |
| 38 |
|
| 39 |
~SecureAuthContext() override = default; |
| 40 |
|
| 41 |
bool IsPeerAuthenticated() const override; |
| 42 |
|
| 43 |
std::vector<grpc::string_ref> GetPeerIdentity() const override; |
| 44 |
|
| 45 |
std::string GetPeerIdentityPropertyName() const override; |
| 46 |
|
| 47 |
std::vector<grpc::string_ref> FindPropertyValues( |
| 48 |
const std::string& name) const override; |
| 49 |
|
| 50 |
AuthPropertyIterator begin() const override; |
| 51 |
|
| 52 |
AuthPropertyIterator end() const override; |
| 53 |
|
| 54 |
void AddProperty(const std::string& key, |
| 55 |
const grpc::string_ref& value) override; |
| 56 |
|
| 57 |
bool SetPeerIdentityPropertyName(const std::string& name) override; |
| 58 |
|
| 59 |
private: |
| 60 |
grpc_core::RefCountedPtr<grpc_auth_context> ctx_; |
| 61 |
}; |
| 62 |
|
| 63 |
} // namespace grpc |
| 64 |
|
| 65 |
#endif // GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H |