dbdriver.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2011, 2012, 2013 Citrix Systems
  3. * Copyright (C) 2014 Vivocha S.p.A.
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the project nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. */
  31. #ifndef __DBDRIVER__
  32. #define __DBDRIVER__
  33. #include "../userdb.h"
  34. #include "ns_turn_msg_defs_new.h"
  35. #include <pthread.h>
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. ////////////////////////////////////////////
  40. extern pthread_key_t connection_key;
  41. extern pthread_once_t connection_key_once;
  42. typedef struct _turn_dbdriver_t {
  43. int (*get_auth_secrets)(secrets_list_t *sl, u08bits *realm);
  44. int (*get_user_key)(u08bits *usname, u08bits *realm, hmackey_t key);
  45. int (*set_user_key)(u08bits *usname, u08bits *realm, const char *key);
  46. int (*del_user)(u08bits *usname, u08bits *realm);
  47. int (*list_users)(u08bits *realm, secrets_list_t *users, secrets_list_t *realms);
  48. int (*list_secrets)(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms);
  49. int (*del_secret)(u08bits *secret, u08bits *realm);
  50. int (*set_secret)(u08bits *secret, u08bits *realm);
  51. int (*add_origin)(u08bits *origin, u08bits *realm);
  52. int (*del_origin)(u08bits *origin);
  53. int (*list_origins)(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms);
  54. int (*set_realm_option_one)(u08bits *realm, unsigned long value, const char* opt);
  55. int (*list_realm_options)(u08bits *realm);
  56. void (*auth_ping)(void * rch);
  57. int (*get_ip_list)(const char *kind, ip_range_list_t * list);
  58. int (*set_permission_ip)(const char *kind, u08bits *realm, const char* ip, int del);
  59. void (*reread_realms)(secrets_list_t * realms_list);
  60. int (*set_oauth_key)(oauth_key_data_raw *key);
  61. int (*get_oauth_key)(const u08bits *kid, oauth_key_data_raw *key);
  62. int (*del_oauth_key)(const u08bits *kid);
  63. int (*list_oauth_keys)(secrets_list_t *kids,secrets_list_t *teas,secrets_list_t *tss,secrets_list_t *lts);
  64. int (*get_admin_user)(const u08bits *usname, u08bits *realm, password_t pwd);
  65. int (*set_admin_user)(const u08bits *usname, const u08bits *realm, const password_t pwd);
  66. int (*del_admin_user)(const u08bits *usname);
  67. int (*list_admin_users)(int no_print);
  68. } turn_dbdriver_t;
  69. /////////// USER DB CHECK //////////////////
  70. int convert_string_key_to_binary(char* keysource, hmackey_t key, size_t sz);
  71. persistent_users_db_t * get_persistent_users_db(void);
  72. const turn_dbdriver_t * get_dbdriver(void);
  73. ////////////////////////////////////////////
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif
  78. /// __DBDRIVER__///