GRPC C++  1.30.0
auth_context.h
Go to the documentation of this file.
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 GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H
20 #define GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H
21 
22 #include <iterator>
23 #include <vector>
24 
27 
28 struct grpc_auth_context;
29 struct grpc_auth_property;
31 
32 namespace grpc {
33 class SecureAuthContext;
34 
35 typedef std::pair<string_ref, string_ref> AuthProperty;
36 
38  : public std::iterator<std::input_iterator_tag, const AuthProperty> {
39  public:
43  bool operator==(const AuthPropertyIterator& rhs) const;
44  bool operator!=(const AuthPropertyIterator& rhs) const;
45  const AuthProperty operator*();
46 
47  protected:
50  const grpc_auth_property_iterator* iter);
51 
52  private:
53  friend class SecureAuthContext;
54  const grpc_auth_property* property_;
55  // The following items form a grpc_auth_property_iterator.
56  const grpc_auth_context* ctx_;
57  size_t index_;
58  const char* name_;
59 };
60 
65 class AuthContext {
66  public:
67  virtual ~AuthContext() {}
68 
70  virtual bool IsPeerAuthenticated() const = 0;
71 
76  virtual std::vector<grpc::string_ref> GetPeerIdentity() const = 0;
77  virtual grpc::string GetPeerIdentityPropertyName() const = 0;
78 
80  virtual std::vector<grpc::string_ref> FindPropertyValues(
81  const grpc::string& name) const = 0;
82 
84  virtual AuthPropertyIterator begin() const = 0;
85  virtual AuthPropertyIterator end() const = 0;
86 
88  virtual void AddProperty(const grpc::string& key,
89  const string_ref& value) = 0;
90  virtual bool SetPeerIdentityPropertyName(const string& name) = 0;
91 };
92 
93 } // namespace grpc
94 
95 #endif // GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H
grpc::string_ref
This class is a non owning reference to a string.
Definition: string_ref.h:41
grpc::AuthContext::GetPeerIdentityPropertyName
virtual grpc::string GetPeerIdentityPropertyName() const =0
grpc_auth_context
struct grpc_auth_context grpc_auth_context
— Authentication Context.
Definition: grpc_security.h:34
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::AuthContext::~AuthContext
virtual ~AuthContext()
Definition: auth_context.h:67
grpc::AuthPropertyIterator::~AuthPropertyIterator
~AuthPropertyIterator()
config.h
grpc::AuthPropertyIterator::operator==
bool operator==(const AuthPropertyIterator &rhs) const
grpc::AuthPropertyIterator::operator*
const AuthProperty operator*()
grpc::AuthContext::FindPropertyValues
virtual std::vector< grpc::string_ref > FindPropertyValues(const grpc::string &name) const =0
Returns all the property values with the given name.
grpc_auth_property_iterator
Definition: grpc_security.h:36
grpc::AuthContext::SetPeerIdentityPropertyName
virtual bool SetPeerIdentityPropertyName(const string &name)=0
grpc::AuthPropertyIterator::operator!=
bool operator!=(const AuthPropertyIterator &rhs) const
grpc::AuthContext::IsPeerAuthenticated
virtual bool IsPeerAuthenticated() const =0
Returns true if the peer is authenticated.
grpc::AuthContext
Class encapsulating the Authentication Information.
Definition: auth_context.h:65
grpc::AuthContext::AddProperty
virtual void AddProperty(const grpc::string &key, const string_ref &value)=0
Mutation functions: should only be used by an AuthMetadataProcessor.
grpc::AuthPropertyIterator::AuthPropertyIterator
AuthPropertyIterator()
grpc_auth_property
value, if not NULL, is guaranteed to be NULL terminated.
Definition: grpc_security.h:43
string_ref.h
grpc::AuthContext::GetPeerIdentity
virtual std::vector< grpc::string_ref > GetPeerIdentity() const =0
A peer identity.
grpc::AuthPropertyIterator::operator++
AuthPropertyIterator & operator++()
grpc::AuthContext::end
virtual AuthPropertyIterator end() const =0
grpc::AuthContext::begin
virtual AuthPropertyIterator begin() const =0
Iteration over all the properties.
grpc::string
std::string string
Definition: config.h:35
grpc::AuthProperty
std::pair< string_ref, string_ref > AuthProperty
Definition: auth_context.h:33
grpc::AuthPropertyIterator::SecureAuthContext
friend class SecureAuthContext
Definition: auth_context.h:53
grpc::AuthPropertyIterator
Definition: auth_context.h:37