sasldb.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* sasldb.h - SASLdb library header
  2. * Rob Siemborski
  3. * Tim Martin
  4. */
  5. /*
  6. * Copyright (c) 1998-2016 Carnegie Mellon University. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The name "Carnegie Mellon University" must not be used to
  21. * endorse or promote products derived from this software without
  22. * prior written permission. For permission or any other legal
  23. * details, please contact
  24. * Carnegie Mellon University
  25. * Center for Technology Transfer and Enterprise Creation
  26. * 4615 Forbes Avenue
  27. * Suite 302
  28. * Pittsburgh, PA 15213
  29. * (412) 268-7393, fax: (412) 268-7395
  30. * innovation@andrew.cmu.edu
  31. *
  32. * 4. Redistributions of any form whatsoever must retain the following
  33. * acknowledgment:
  34. * "This product includes software developed by Computing Services
  35. * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
  36. *
  37. * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
  38. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  39. * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
  40. * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  41. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  42. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  43. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  44. */
  45. #ifndef SASLDB_H
  46. #define SASLDB_H
  47. #include "sasl.h"
  48. #include "saslplug.h"
  49. /*
  50. * Note that some of these require a sasl_conn_t in order for
  51. * the getcallback stuff to work correctly. This is great for
  52. * when they are called from a plugin or the library but makes
  53. * for much wierdness when an otherwise non-sasl application needs
  54. * to make use of this functionality.
  55. */
  56. int _sasldb_getdata(const sasl_utils_t *utils,
  57. sasl_conn_t *conn,
  58. const char *authid,
  59. const char *realm,
  60. const char *propName,
  61. char *out, const size_t max_out, size_t *out_len);
  62. /* pass NULL for data to delete it */
  63. int _sasldb_putdata(const sasl_utils_t *utils,
  64. sasl_conn_t *conn,
  65. const char *authid,
  66. const char *realm,
  67. const char *propName,
  68. const char *data, size_t data_len);
  69. /* Should be run before any db access is attempted */
  70. LIBSASL_API int _sasl_check_db(const sasl_utils_t *utils,
  71. sasl_conn_t *conn);
  72. /* These allow iterating through the keys of the database */
  73. typedef void* sasldb_handle;
  74. typedef int (* sasldb_list_callback_t) (const char *authid,
  75. const char *realm,
  76. const char *property,
  77. void *rock);
  78. LIBSASL_API sasldb_handle _sasldb_getkeyhandle(const sasl_utils_t *utils,
  79. sasl_conn_t *conn);
  80. LIBSASL_API int _sasldb_getnextkey(const sasl_utils_t *utils,
  81. sasldb_handle handle, char *out,
  82. const size_t max_out, size_t *out_len);
  83. LIBSASL_API int _sasldb_releasekeyhandle(const sasl_utils_t *utils,
  84. sasldb_handle handle);
  85. LIBSASL_API int _sasldb_listusers(const sasl_utils_t *utils,
  86. sasl_conn_t *context,
  87. sasldb_list_callback_t callback,
  88. void *callback_rock);
  89. #if defined(KEEP_DB_OPEN)
  90. void sasldb_auxprop_free (void *glob_context, const sasl_utils_t *utils);
  91. #else
  92. #define sasldb_auxprop_free NULL
  93. #endif
  94. /* The rest are implemented in allockey.c and individual drivers need not
  95. * do so */
  96. /* These two are aliases for getdata/putdata */
  97. int _sasldb_getsecret(const sasl_utils_t *utils,
  98. sasl_conn_t *context,
  99. const char *auth_identity,
  100. const char *realm,
  101. sasl_secret_t ** secret);
  102. int _sasldb_putsecret(const sasl_utils_t *utils,
  103. sasl_conn_t *context,
  104. const char *auth_identity,
  105. const char *realm,
  106. const sasl_secret_t * secret);
  107. LIBSASL_API int _sasldb_parse_key(const char *key, const size_t key_len,
  108. char *authid, const size_t max_authid,
  109. char *realm, const size_t max_realm,
  110. char *propName, const size_t max_propname);
  111. /* This function is internal, but might be useful to have around */
  112. int _sasldb_alloc_key(const sasl_utils_t *utils,
  113. const char *auth_identity,
  114. const char *realm,
  115. const char *propName,
  116. char **key,
  117. size_t *key_len);
  118. #endif /* SASLDB_H */