You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

alts_context.h 2.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. {
  27. namespace experimental
  28. {
  29. // AltsContext is a wrapper class for grpc_gcp_AltsContext.
  30. class AltsContext
  31. {
  32. public:
  33. struct RpcProtocolVersions
  34. {
  35. struct Version
  36. {
  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. std::string application_protocol() const;
  47. std::string record_protocol() const;
  48. std::string peer_service_account() const;
  49. std::string local_service_account() const;
  50. grpc_security_level security_level() const;
  51. RpcProtocolVersions peer_rpc_versions() const;
  52. const std::map<std::string, std::string>& peer_attributes() const;
  53. private:
  54. std::string application_protocol_;
  55. std::string record_protocol_;
  56. std::string peer_service_account_;
  57. std::string local_service_account_;
  58. grpc_security_level security_level_ = GRPC_SECURITY_NONE;
  59. RpcProtocolVersions peer_rpc_versions_ = {{0, 0}, {0, 0}};
  60. std::map<std::string, std::string> peer_attributes_map_;
  61. };
  62. } // namespace experimental
  63. } // namespace grpc
  64. #endif // GRPCPP_SECURITY_ALTS_CONTEXT_H