Debian Codegraph @

include/libaccess/usrcache.h

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