certmap.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * END COPYRIGHT BLOCK **/
  6. #ifndef _LDAPU_CERTMAP_H
  7. #define _LDAPU_CERTMAP_H
  8. #ifndef INTLDAPU
  9. #define INTLDAPU
  10. #endif /* INTLDAPU */
  11. #include "extcmap.h"
  12. enum {
  13. LDAPU_STR_FILTER_DEFAULT,
  14. LDAPU_STR_FILTER_USER,
  15. LDAPU_STR_FILTER_GROUP,
  16. LDAPU_STR_FILTER_MEMBER,
  17. LDAPU_STR_FILTER_MEMBER_RECURSE,
  18. LDAPU_STR_ATTR_USER,
  19. LDAPU_STR_ATTR_CERT,
  20. LDAPU_STR_ATTR_CERT_NOSUBTYPE,
  21. LDAPU_STR_MAX_INDEX
  22. };
  23. static char *ldapu_strings[] = {
  24. "objectclass=*", /* LDAPU_STR_DEFAULT */
  25. "uid=%s", /* LDAPU_STR_FILTER_USER */
  26. "(& (cn=%s) (| (objectclass=groupofuniquenames) (objectclass=groupofnames)))", /* LDAPU_STR_FILTER_GROUP */
  27. "(| (uniquemember=%s) (member=%s))", /* LDAPU_STR_FILTER_MEMBER */
  28. "(& %s (| (objectclass=groupofuniquenames) (objectclass=groupofnames))", /* LDAPU_STR_FILTER_MEMBER_RECURSE */
  29. "uid", /* LDAPU_STR_ATTR_USER */
  30. "userCertificate;binary", /* LDAPU_STR_ATTR_CERT */
  31. "userCertificate" /* LDAPU_STR_ATTR_CERT_NOSUBTYPE */
  32. };
  33. typedef struct {
  34. char *str;
  35. int size;
  36. int len;
  37. } LDAPUStr_t;
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. NSAPI_PUBLIC int ldapu_cert_to_ldap_entry (void *cert, LDAP *ld,
  42. const char *basedn,
  43. LDAPMessage **res);
  44. NSAPI_PUBLIC int ldapu_set_cert_mapfn (const char *issuerDN,
  45. CertMapFn_t mapfn);
  46. NSAPI_PUBLIC CertMapFn_t ldapu_get_cert_mapfn (const char *issuerDN);
  47. NSAPI_PUBLIC int ldapu_set_cert_searchfn (const char *issuerDN,
  48. CertSearchFn_t searchfn);
  49. NSAPI_PUBLIC CertSearchFn_t ldapu_get_cert_searchfn (const char *issuerDN);
  50. NSAPI_PUBLIC int ldapu_set_cert_verifyfn (const char *issuerDN,
  51. CertVerifyFn_t verifyFn);
  52. NSAPI_PUBLIC CertVerifyFn_t ldapu_get_cert_verifyfn (const char *issuerDN);
  53. NSAPI_PUBLIC int ldapu_get_cert_subject_dn (void *cert, char **subjectDN);
  54. NSAPI_PUBLIC int ldapu_get_cert_issuer_dn (void *cert, char **issuerDN);
  55. NSAPI_PUBLIC int ldapu_get_cert_ava_val (void *cert, int which_dn,
  56. const char *attr, char ***val);
  57. NSAPI_PUBLIC int ldapu_free_cert_ava_val (char **val);
  58. NSAPI_PUBLIC int ldapu_get_cert_der (void *cert, unsigned char **derCert,
  59. unsigned int *len);
  60. NSAPI_PUBLIC int ldapu_issuer_certinfo (const char *issuerDN,
  61. void **certmap_info);
  62. NSAPI_PUBLIC int ldapu_certmap_info_attrval (void *certmap_info,
  63. const char *attr, char **val);
  64. NSAPI_PUBLIC char *ldapu_err2string (int err);
  65. /* Keep the old fn for backward compatibility */
  66. NSAPI_PUBLIC void ldapu_free_old (char *ptr);
  67. NSAPI_PUBLIC void *ldapu_malloc (int size);
  68. NSAPI_PUBLIC char *ldapu_strdup (const char *ptr);
  69. NSAPI_PUBLIC void *ldapu_realloc (void *ptr, int size);
  70. NSAPI_PUBLIC void ldapu_free (void *ptr);
  71. NSAPI_PUBLIC int ldapu_string_set (const int type, const char *filter);
  72. NSAPI_PUBLIC const char *ldapu_string_get (const int type);
  73. NSAPI_PUBLIC int ldaputil_exit ();
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif /* _LDAPU_CERTMAP_H */