1 /* 2 * 3 * Copyright 2019 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_SECURITY_ALTS_CONTEXT_H 20 #define GRPCPP_SECURITY_ALTS_CONTEXT_H 21 22 #include <grpc/grpc_security_constants.h> 23 #include <grpcpp/security/auth_context.h> 24 25 #include <map> 26 #include <memory> 27 28 struct grpc_gcp_AltsContext; 29 30 namespace grpc { 31 namespace experimental { 32 33 // AltsContext is a wrapper class for grpc_gcp_AltsContext. 34 class AltsContext { 35 public: 36 struct RpcProtocolVersions { 37 struct Version { 38 int major_version; 39 int minor_version; 40 }; 41 Version max_rpc_version; 42 Version min_rpc_version; 43 }; 44 explicit AltsContext(const grpc_gcp_AltsContext* ctx); 45 AltsContext& operator=(const AltsContext&) = default; 46 AltsContext(const AltsContext&) = default; 47 48 std::string application_protocol() const; 49 std::string record_protocol() const; 50 std::string peer_service_account() const; 51 std::string local_service_account() const; 52 grpc_security_level security_level() const; 53 RpcProtocolVersions peer_rpc_versions() const; 54 const std::map<std::string, std::string>& peer_attributes() const; 55 56 private: 57 std::string application_protocol_; 58 std::string record_protocol_; 59 std::string peer_service_account_; 60 std::string local_service_account_; 61 grpc_security_level security_level_ = GRPC_SECURITY_NONE; 62 RpcProtocolVersions peer_rpc_versions_ = {{0, 0}, {0, 0}}; 63 std::map<std::string, std::string> peer_attributes_map_; 64 }; 65 66 } // namespace experimental 67 } // namespace grpc 68 69 #endif // GRPCPP_SECURITY_ALTS_CONTEXT_H 70