GRPC C++  1.26.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;
30 struct grpc_auth_property_iterator;
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:
49  AuthPropertyIterator(const grpc_auth_property* property,
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
std::string string
Definition: config.h:35
Class encapsulating the Authentication Information.
Definition: auth_context.h:65
bool operator==(const AuthPropertyIterator &rhs) const
std::pair< string_ref, string_ref > AuthProperty
Definition: auth_context.h:33
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
const AuthProperty operator*()
virtual ~AuthContext()
Definition: auth_context.h:67
bool operator!=(const AuthPropertyIterator &rhs) const
AuthPropertyIterator & operator++()
This class is a non owning reference to a string.
Definition: string_ref.h:41
Definition: auth_context.h:37
friend class SecureAuthContext
Definition: auth_context.h:53