security_context.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. *
  3. * Copyright 2015, Google Inc.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are
  8. * met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above
  13. * copyright notice, this list of conditions and the following disclaimer
  14. * in the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Google Inc. nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. */
  33. #ifndef GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H
  34. #define GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H
  35. #include "src/core/security/credentials.h"
  36. /* --- grpc_auth_context ---
  37. High level authentication context object. Can optionally be chained. */
  38. /* Property names are always NULL terminated. */
  39. struct grpc_auth_context {
  40. struct grpc_auth_context *chained;
  41. grpc_auth_property *properties;
  42. size_t property_count;
  43. gpr_refcount refcount;
  44. const char *peer_identity_property_name;
  45. };
  46. /* Constructor. */
  47. grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained,
  48. size_t property_count);
  49. /* Refcounting. */
  50. grpc_auth_context *grpc_auth_context_ref(
  51. grpc_auth_context *ctx);
  52. void grpc_auth_context_unref(grpc_auth_context *ctx);
  53. grpc_auth_property grpc_auth_property_init_from_cstring(const char *name,
  54. const char *value);
  55. grpc_auth_property grpc_auth_property_init(const char *name, const char *value,
  56. size_t value_length);
  57. void grpc_auth_property_reset(grpc_auth_property *property);
  58. /* --- grpc_client_security_context ---
  59. Internal client-side security context. */
  60. typedef struct {
  61. grpc_credentials *creds;
  62. grpc_auth_context *auth_context;
  63. } grpc_client_security_context;
  64. grpc_client_security_context *grpc_client_security_context_create(void);
  65. void grpc_client_security_context_destroy(void *ctx);
  66. /* --- grpc_server_security_context ---
  67. Internal server-side security context. */
  68. typedef struct {
  69. grpc_auth_context *auth_context;
  70. } grpc_server_security_context;
  71. grpc_server_security_context *grpc_server_security_context_create(void);
  72. void grpc_server_security_context_destroy(void *ctx);
  73. #endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */