certmap.h 3.1 KB

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