usrcache.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef ACL_USER_CACHE_H
  13. #define ACL_USER_CACHE_H
  14. #include <plhash.h>
  15. #include <sys/types.h>
  16. #include <time.h>
  17. /* Removed for new ns security integration
  18. #include <sec.h>
  19. */
  20. #include <key.h>
  21. #include <cert.h>
  22. #include <prclist.h>
  23. typedef struct {
  24. PRCList list; /* pointer to next & prev obj */
  25. char *uid; /* unique within a database */
  26. char *userdn; /* LDAP DN if using LDAP db */
  27. char *passwd; /* password */
  28. SECItem *derCert; /* raw certificate data */
  29. char *group; /* group recently checked for membership */
  30. time_t time; /* last time when the cache was validated */
  31. PRHashTable *hashtable; /* hash table where this obj is being used */
  32. } UserCacheObj;
  33. NSPR_BEGIN_EXTERN_C
  34. /* Set the number of seconds the cache is valid */
  35. extern int acl_usr_cache_set_timeout (const int nsec);
  36. /* Is the cache enabled? */
  37. extern int acl_usr_cache_enabled();
  38. /* initialize user cache */
  39. extern int acl_usr_cache_init ();
  40. /* Creates a new user obj entry */
  41. extern int acl_usr_cache_insert (const char *uid, const char *dbname,
  42. const char *dn, const char *passwd,
  43. const char *group, const SECItem *derCert,
  44. const time_t time);
  45. /* Add group to the user's cache obj. */
  46. extern int acl_usr_cache_set_group (const char *uid, const char *dbname,
  47. const char *group, const time_t time);
  48. /* Add userdn to the user's cache obj. */
  49. extern int acl_usr_cache_set_userdn (const char *uid, const char *dbname,
  50. const char *userdn, const time_t time);
  51. /* Returns LAS_EVAL_TRUE if the user's password matches -- also returns the dn */
  52. extern int acl_usr_cache_passwd_check (const char *uid, const char *dbname,
  53. const char *passwd,
  54. const time_t time, char **dn,
  55. pool_handle_t *pool);
  56. /* Returns LAS_EVAL_TRUE if the user is a member of the group */
  57. extern int acl_usr_cache_group_check (const char *uid, const char *dbname,
  58. const char *group, const time_t time);
  59. /* Returns LAS_EVAL_TRUE if the user is a member of the group */
  60. extern int acl_usr_cache_group_len_check (const char *uid, const char *dbname,
  61. const char *group,
  62. const int len,
  63. const time_t time);
  64. /* Returns LAS_EVAL_TRUE if the user's cache is valid and has a group */
  65. extern int acl_usr_cache_get_group (const char *uid, const char *dbname,
  66. const time_t time, char **group,
  67. pool_handle_t *pool);
  68. /* Returns LAS_EVAL_TRUE if the user is a member of the group */
  69. extern int acl_usr_cache_userdn_check (const char *uid, const char *dbname,
  70. const char *userdn, const time_t time);
  71. /* Returns LAS_EVAL_TRUE if the user's cache is valid and has userdn */
  72. extern int acl_usr_cache_get_userdn (const char *uid, const char *dbname,
  73. const time_t time, char **userdn,
  74. pool_handle_t *pool);
  75. /* Creates a new user obj entry for cert to user mapping */
  76. extern int acl_cert_cache_insert (void *cert, const char *dbname,
  77. const char *uid, const char *dn,
  78. const time_t time);
  79. /* Returns LAS_EVAL_TRUE if the user's cache is valid and returns uid */
  80. extern int acl_cert_cache_get_uid (void *cert, const char *dbname,
  81. const time_t time, char **uid,
  82. char **dn, pool_handle_t *pool);
  83. NSPR_END_EXTERN_C
  84. #endif /* ACL_USER_CACHE_H */