alts_context.h 2.0 KB

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