diff options
author | 2015-09-14 13:18:14 -0400 | |
---|---|---|
committer | 2015-09-14 13:18:14 -0400 | |
commit | f798b779fc35e0be603f07589f3f27efa316da7f (patch) | |
tree | 7c9e0b908218f6ed6207139c2065c6b78358fa5a /src/cpp/common/secure_auth_context.cc | |
parent | 780b07e6442b06039a936382ce10fe0c4a30f4af (diff) | |
parent | 261666696496174f824d9e43a60559040eda3055 (diff) |
Merge remote-tracking branch 'upstream/master' into rename_callback
Diffstat (limited to 'src/cpp/common/secure_auth_context.cc')
-rw-r--r-- | src/cpp/common/secure_auth_context.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/cpp/common/secure_auth_context.cc b/src/cpp/common/secure_auth_context.cc index b18a8537c9..8615ac8aeb 100644 --- a/src/cpp/common/secure_auth_context.cc +++ b/src/cpp/common/secure_auth_context.cc @@ -37,9 +37,13 @@ namespace grpc { -SecureAuthContext::SecureAuthContext(grpc_auth_context* ctx) : ctx_(ctx) {} +SecureAuthContext::SecureAuthContext(grpc_auth_context* ctx, + bool take_ownership) + : ctx_(ctx), take_ownership_(take_ownership) {} -SecureAuthContext::~SecureAuthContext() { grpc_auth_context_release(ctx_); } +SecureAuthContext::~SecureAuthContext() { + if (take_ownership_) grpc_auth_context_release(ctx_); +} std::vector<grpc::string_ref> SecureAuthContext::GetPeerIdentity() const { if (!ctx_) { @@ -94,4 +98,21 @@ AuthPropertyIterator SecureAuthContext::end() const { return AuthPropertyIterator(); } +void SecureAuthContext::AddProperty(const grpc::string& key, + const grpc::string_ref& value) { + if (!ctx_) return; + grpc_auth_context_add_property(ctx_, key.c_str(), value.data(), value.size()); +} + +bool SecureAuthContext::SetPeerIdentityPropertyName(const grpc::string& name) { + if (!ctx_) return false; + return grpc_auth_context_set_peer_identity_property_name(ctx_, + name.c_str()) != 0; +} + +bool SecureAuthContext::IsPeerAuthenticated() const { + if (!ctx_) return false; + return grpc_auth_context_peer_is_authenticated(ctx_) != 0; +} + } // namespace grpc |