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 <memory> 26 27 struct grpc_gcp_AltsContext; 28 29 namespace grpc { 30 namespace experimental { 31 32 // AltsContext is a wrapper class for grpc_gcp_AltsContext. 33 class AltsContext { 34 public: 35 struct RpcProtocolVersions { 36 struct Version { 37 int major_version; 38 int minor_version; 39 }; 40 Version max_rpc_version; 41 Version min_rpc_version; 42 }; 43 explicit AltsContext(const grpc_gcp_AltsContext* ctx); 44 AltsContext& operator=(const AltsContext&) = default; 45 AltsContext(const AltsContext&) = default; 46 47 std::string application_protocol() const; 48 std::string record_protocol() const; 49 std::string peer_service_account() const; 50 std::string local_service_account() const; 51 grpc_security_level security_level() const; 52 RpcProtocolVersions peer_rpc_versions() const; 53 54 private: 55 // TODO(ZhenLian): Also plumb field peer_attributes when it is in use 56 std::string application_protocol_; 57 std::string record_protocol_; 58 std::string peer_service_account_; 59 std::string local_service_account_; 60 grpc_security_level security_level_ = GRPC_SECURITY_NONE; 61 RpcProtocolVersions peer_rpc_versions_ = {{0, 0}, {0, 0}}; 62 }; 63 64 } // namespace experimental 65 } // namespace grpc 66 67 #endif // GRPCPP_SECURITY_ALTS_CONTEXT_H 68