Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

756 lines
23 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. iismap.hxx
  5. Abstract:
  6. Headers for classes to handle mapping
  7. --*/
  8. /*
  9. Usage:
  10. 3 mapper classes are defined, all of them derived from CIisAcctMapper :
  11. - CIisCertMapper : SSL certificate mapping
  12. - CIisItaMapper : Internet account ( basic authentication ) mapping
  13. - CIisMd5Mapper : Digest authentication account mapping
  14. An instance of one these classes must be created by the client.
  15. This instance must be initialized ( call to Init() ) and terminated
  16. ( call to Terminate() ) before and after use.
  17. Load() / Save() load and save the current mapping. Changes made to the
  18. mappings are not commited until Save() is called.
  19. The file integrity will be checked at load time, error ERROR_BAD_FORMAT will
  20. be returned if format is corrupted, ERROR_INVALID_ACCESS if the file was
  21. modified by an application without using this library. In the later case
  22. the content is valid, and can be validated by calling Save().
  23. Each class defines a field list ( MappingGetFieldList() ), a field being
  24. defined by its type ( IISMDB_TYPE_* ), displayable name
  25. and maximum width ( characters )
  26. Each class also defines a hierarchy of fields used in the mapping process.
  27. The hierarchy is defined by an array of descriptor ( index in field list array
  28. and mandatory flag. The mandatory flag indicates whether this field must be
  29. present when a new mapping is created, it is an indication intended for the UI )
  30. The hierarchy is accessed by GetHierarchy() and is modified in place.
  31. A call to UpdateHierarchy() is necessary after any modification to the
  32. hierarchy.
  33. An option bit ( GetOptions() & IISMDB_OPTION_EDIT_HIERARCHY ) indicates
  34. whether the hierarcht is editable for a given class or not.
  35. Mapping entries are accessed through GetNbMapping(), GetMapping( 0-based index ).
  36. To add a mapping, call CreateNewMapping() then Add() or delete the created
  37. mapping.
  38. To update a mapping, access it using GetMapping() then call Update().
  39. To delete a mapping, call Delete().
  40. Each mapping is derived from CIisMapping.
  41. Fields are get/set using MappingGetField() / MappingSetField().
  42. Each class storage is controlled by a registry key as defined by
  43. IIS_*_MAPPER_REG. Two values must be created :
  44. - FileLocation:REG_SZ, which is the full path of the file used to store
  45. the mappings
  46. - FileValidator:REG_BINARY, which will be used by this library
  47. to store/check a MD5 digest of the file content to check file integrity
  48. Features specific to SSL certificate mappings ( CIisCertMapper ):
  49. - a list of BLOBs is to be created/edited by the UI through
  50. SetIssuerList()/GetIssuerList().
  51. Each BLOB describes a certificate issuer. Exact format to be defined
  52. by the Crypto team, but can assumed to be ASN.1 description of issuer.
  53. This list will be used by the SSL package to request the client to send
  54. a list of certificates issued by one of the issuer in this list.
  55. */
  56. extern "C" {
  57. #include <md5.h>
  58. #include <immd5.h>
  59. }
  60. #include <xbf.hxx>
  61. typedef LPVOID VALID_CTX;
  62. #if !defined(dllexp)
  63. #define dllexp __declspec( dllexport )
  64. #endif
  65. //
  66. // Field types, can be used to associate semantic to each field
  67. // (e.g. not displaying password in clear text but as '*' )
  68. //
  69. #define IISMDB_TYPE_STRING 0 // generic string
  70. #define IISMDB_TYPE_PWD 1 // clear text password
  71. #define IISMDB_TYPE_NTACCT 2 // NT account ([Domain\]UserName)
  72. #define IISMDB_TYPE_ISSUER_O 3 // Certificate Issuer Organization
  73. #define IISMDB_TYPE_ISSUER_OU 4 // Certificate Issuer Organization Unit
  74. #define IISMDB_TYPE_ISSUER_C 5 // Certificate Issuer Country
  75. #define IISMDB_TYPE_SUBJECT_O 6 // Certificate Subject Organization
  76. #define IISMDB_TYPE_SUBJECT_OU 7 // Certificate Subject Organization Unit
  77. #define IISMDB_TYPE_SUBJECT_C 8 // Certificate Subject Country
  78. #define IISMDB_TYPE_SUBJECT_CN 9 // Certificate Subject Name
  79. #define IISMDB_TYPE_ITACCT 10 // Internet account
  80. #define IISMDB_TYPE_ITPWD 11 // Internet password, stored as MD5 digest
  81. #define IISMDB_TYPE_ITREALM 12 // Internet realm
  82. #define IISMDB_TYPE_ITMD5PWD 13 // Internet password, stored as MD5 digest
  83. // of Account ":" Realm ":" Clear-text password
  84. #define IISMDB_TYPE_NTPWD 14 // NT password
  85. #define IISMDB_TYPE_OPTION_MASK 0xff000000
  86. #define IISMDB_TYPE_BINARY 0x80000000
  87. //
  88. // Field indexes for SSL certificates mapping
  89. //
  90. #define IISMDB_INDEX_ISSUER_O 0
  91. #define IISMDB_INDEX_ISSUER_OU 1
  92. #define IISMDB_INDEX_ISSUER_C 2
  93. #define IISMDB_INDEX_SUBJECT_O 3
  94. #define IISMDB_INDEX_SUBJECT_OU 4
  95. #define IISMDB_INDEX_SUBJECT_C 5
  96. #define IISMDB_INDEX_SUBJECT_CN 6
  97. #define IISMDB_INDEX_NT_ACCT 7
  98. #define IISMDB_INDEX_NB 8 // must be last
  99. //
  100. // Field indexes for Internet accounts ( basic authentication ) mapping
  101. //
  102. #define IISIMDB_INDEX_IT_ACCT 0
  103. #define IISIMDB_INDEX_IT_PWD 1
  104. #define IISIMDB_INDEX_NT_ACCT 2
  105. #define IISIMDB_INDEX_NT_PWD 3
  106. #define IISIMDB_INDEX_NB 4 // must be last
  107. //
  108. // Field indexes for Digest authentication mapping
  109. //
  110. #define IISMMDB_INDEX_IT_REALM 0
  111. #define IISMMDB_INDEX_IT_ACCT 1
  112. #define IISMMDB_INDEX_IT_MD5PWD 2
  113. #define IISMMDB_INDEX_NT_ACCT 3
  114. #define IISMMDB_INDEX_IT_CLRPWD 4
  115. #define IISMMDB_INDEX_NT_PWD 5
  116. #define IISMMDB_INDEX_NB 6 // must be last
  117. //
  118. // Client cert to NT acct 1:1 mapping
  119. //
  120. #define CERT11_FULL_CERT
  121. #if defined(CERT11_FULL_CERT)
  122. #define IISMDB_INDEX_CERT11_CERT 0
  123. #define IISMDB_INDEX_CERT11_NT_ACCT 1
  124. #define IISMDB_INDEX_CERT11_NAME 2
  125. #define IISMDB_INDEX_CERT11_ENABLED 3
  126. #define IISMDB_INDEX_CERT11_NT_PWD 4
  127. #define IISMDB_INDEX_CERT11_NB 5
  128. #else
  129. #define IISMDB_INDEX_CERT11_SUBJECT 0
  130. #define IISMDB_INDEX_CERT11_ISSUER 1
  131. #define IISMDB_INDEX_CERT11_NT_ACCT 2
  132. #define IISMDB_INDEX_CERT11_NB 3
  133. #endif
  134. // options
  135. // set if hierarchy to be edited by user
  136. #define IISMDB_OPTION_EDIT_HIERARCHY 0x00000001
  137. #define IISMDB_OPTION_ISSUER_LIST 0x00000002
  138. #define IISMDB_CERT_OPTIONS (IISMDB_OPTION_EDIT_HIERARCHY|IISMDB_OPTION_ISSUER_LIST)
  139. #define IISMDB_CERT11_OPTIONS (IISMDB_OPTION_ISSUER_LIST)
  140. #define IISMDB_ITA_OPTIONS 0
  141. #define IISMDB_MD5_OPTIONS 0
  142. // version #
  143. #define IISMDB_VERSION_1 1
  144. #define IISMDB_CURRENT_VERSION IISMDB_VERSION_1
  145. #define IISMDB_FILE_MAGIC_VALUE (('B'<<24)|('D'<<16)|('M'<<8)|('I'))
  146. #define IIS_CERT_MAPPER_REG "SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters\\CertMapper"
  147. #define IIS_ITA_MAPPER_REG "SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters\\ItaMapper"
  148. #define IIS_MD5_MAPPER_REG "SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters\\Md5Mapper"
  149. #define IIS_CERT11_MAPPER_REG "SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters\\Cert11Mapper"
  150. #define W3_PARAMS "SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters"
  151. #define INSTALL_PATH "InstallPath"
  152. #define MAPPER_GUID "MapperGuid"
  153. // REG_BINARY : MD5 digest of file content
  154. #define FILE_VALIDATOR "FileValidator"
  155. // REG_SZ : file name
  156. #define FILE_LOCATION "FileLocation"
  157. #define IIS_CERT_FILENAME "iiscert.mp"
  158. #define IIS_IT_FILENAME "iisita.mp"
  159. #define IIS_MD5_FILENAME "iismd5.mp"
  160. #define IIS_CERT11_FILENAME "iiscr11.mp"
  161. //
  162. // Mapping array allocation extension granularity
  163. //
  164. #define IIS_MAP_BUFF_GRAN 128
  165. typedef struct _Cert_Map {
  166. DWORD cbIssuerLen;
  167. LPBYTE pIssuer;
  168. DWORD cbSubjectLen;
  169. LPBYTE pSubject;
  170. } Cert_Map ;
  171. //
  172. // Field descriptor
  173. //
  174. typedef struct _IISMDB_Fields {
  175. DWORD m_dwType;
  176. LPSTR m_pszDisplayName;
  177. DWORD m_dwResID;
  178. DWORD m_dwMaxLen;
  179. } IISMDB_Fields;
  180. //
  181. // Field Hierarchy descriptor
  182. //
  183. typedef struct _IISMDB_HEntry {
  184. DWORD m_dwIndex;
  185. BOOL m_fMandatory;;
  186. } IISMDB_HEntry;
  187. class CIisAcctMapper;
  188. class CIisMapping {
  189. public:
  190. CIisMapping();
  191. ~CIisMapping() { if ( m_pBuff != NULL ) LocalFree( m_pBuff ); }
  192. //
  193. dllexp virtual BOOL Serialize( FILE*, VALID_CTX, LPVOID );
  194. dllexp virtual BOOL Deserialize( FILE*, VALID_CTX, LPVOID );
  195. virtual BOOL StoreFieldRef( DWORD iIndex, LPSTR pf ) { return FALSE; }
  196. virtual BOOL StoreFieldRef( DWORD iIndex, LPSTR pf, DWORD dwL ) { return FALSE; }
  197. virtual BOOL IsCrypt( DWORD iIndex ) { return FALSE; }
  198. int Cmp( CIisMapping*, BOOL fCmpForMatch = FALSE );
  199. DWORD GetMask() { return m_dwMask; }
  200. dllexp BOOL UpdateMask( IISMDB_HEntry*, DWORD );
  201. dllexp BOOL Copy( CIisMapping* );
  202. BOOL StoreField(
  203. LPSTR* ppszFields,
  204. DWORD dwIndex,
  205. DWORD dwNbIndex,
  206. LPSTR pszNew
  207. );
  208. BOOL StoreField(
  209. LPSTR* ppszFields,
  210. LPDWORD ppdwFields,
  211. DWORD dwIndex,
  212. DWORD dwNbIndex,
  213. LPSTR pszNew,
  214. DWORD cNew,
  215. BOOL fIsUuEncoded
  216. );
  217. public:
  218. // stores a copy to storage pointed to by pF
  219. dllexp virtual BOOL MappingSetField( DWORD iIndex, LPSTR pF );
  220. dllexp virtual BOOL MappingSetField( DWORD iIndex, LPSTR pF, DWORD cF, BOOL );
  221. // return a pointer to internal storage
  222. dllexp virtual BOOL MappingGetField( DWORD iIndex, LPSTR* );
  223. dllexp virtual BOOL MappingGetField( DWORD iIndex, LPSTR*, LPDWORD, BOOL );
  224. dllexp virtual UINT GetNbField( LPSTR ** ) { return 0; }
  225. dllexp virtual UINT GetNbField( LPSTR **, LPDWORD* ) { return 0; }
  226. dllexp virtual BOOL Clone( CIisMapping** ) { return FALSE; }
  227. dllexp BOOL CloneEx( CIisMapping**, LPSTR*, LPSTR*, LPDWORD, LPDWORD, UINT );
  228. protected:
  229. LPBYTE m_pBuff;
  230. UINT m_cUsedBuff;
  231. UINT m_cAllocBuff;
  232. CIisAcctMapper *m_pMapper;
  233. DWORD m_dwMask;
  234. } ;
  235. class CCertMapping : public CIisMapping {
  236. public:
  237. dllexp CCertMapping();
  238. dllexp CCertMapping( CIisAcctMapper* );
  239. dllexp ~CCertMapping();
  240. //
  241. #if defined(DECODE_ASN1)
  242. BOOL Init( Cert_Map *pC, IISMDB_HEntry *pH, DWORD dwH );
  243. BOOL Init( const LPBYTE pC, DWORD cC, IISMDB_HEntry *pH, DWORD dwH );
  244. #endif
  245. BOOL StoreFieldRef( DWORD iIndex, LPSTR pF ) { m_pFields[iIndex] = pF; return TRUE; }
  246. //
  247. UINT GetNbField(LPSTR **pF) { *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  248. UINT GetNbField(LPSTR **pF, LPDWORD *pC) { *pC = NULL; *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  249. BOOL Clone( CIisMapping** ppM)
  250. {
  251. if ( *ppM = new CCertMapping( m_pMapper ) )
  252. {
  253. return CloneEx( ppM, ((CCertMapping*)*ppM)->m_pFields, m_pFields, NULL, NULL, IISMDB_INDEX_NB );
  254. }
  255. return FALSE;
  256. }
  257. private:
  258. LPSTR m_pFields[IISMDB_INDEX_NB];
  259. } ;
  260. class CCert11Mapping : public CIisMapping {
  261. public:
  262. dllexp CCert11Mapping();
  263. dllexp CCert11Mapping( CIisAcctMapper* );
  264. dllexp ~CCert11Mapping();
  265. //
  266. #if defined(CERT11_FULL_CERT)
  267. BOOL Init( LPBYTE pC, DWORD cC, IISMDB_HEntry *pH, DWORD dwH );
  268. #else
  269. BOOL Init( LPBYTE pI, DWORD cI, LPBYTE pS, DWORD cS, IISMDB_HEntry *pH, DWORD dwH );
  270. #endif
  271. BOOL StoreFieldRef( DWORD iIndex, LPSTR pF ) { m_pFields[iIndex] = pF; return TRUE; }
  272. BOOL StoreFieldRef( DWORD iIndex, LPSTR pF, DWORD dwF ) { m_pFields[iIndex] = pF; m_cFields[iIndex] = dwF; return TRUE; }
  273. BOOL IsCrypt( DWORD iIndex ) { return (iIndex == IISMDB_INDEX_CERT11_NT_PWD) ? TRUE : FALSE; }
  274. //
  275. UINT GetNbField(LPSTR **pF) { *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  276. UINT GetNbField(LPSTR **pF, LPDWORD *pcF) { *pF = m_pFields; *pcF = m_cFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  277. BOOL MappingSetField( DWORD iIndex, LPSTR pF );
  278. BOOL Clone( CIisMapping** ppM)
  279. {
  280. if ( *ppM = new CCert11Mapping( m_pMapper ) )
  281. {
  282. return CloneEx( ppM, ((CCert11Mapping*)*ppM)->m_pFields, m_pFields, ((CCert11Mapping*)*ppM)->m_cFields, m_cFields, IISMDB_INDEX_CERT11_NB );
  283. }
  284. return FALSE;
  285. }
  286. private:
  287. LPSTR m_pFields[IISMDB_INDEX_CERT11_NB];
  288. DWORD m_cFields[IISMDB_INDEX_CERT11_NB];
  289. } ;
  290. class CItaMapping : public CIisMapping {
  291. public:
  292. dllexp CItaMapping();
  293. dllexp CItaMapping( CIisAcctMapper* );
  294. dllexp ~CItaMapping();
  295. //
  296. BOOL Init( LPSTR pszType, LPSTR pszName, LPSTR pszPwd, IISMDB_HEntry *pH, DWORD dwH );
  297. BOOL StoreFieldRef( DWORD iIndex, LPSTR pF ) { m_pFields[iIndex] = pF; return TRUE; }
  298. BOOL IsCrypt( DWORD iIndex ) { return (iIndex == IISIMDB_INDEX_NT_PWD) ? TRUE : FALSE; }
  299. //
  300. UINT GetNbField(LPSTR **pF) { *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  301. UINT GetNbField(LPSTR **pF, LPDWORD *pC) { *pC = NULL; *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  302. dllexp BOOL MappingSetField( DWORD iIndex, LPSTR );
  303. BOOL Clone( CIisMapping** ppM)
  304. {
  305. if ( *ppM = new CItaMapping( m_pMapper ) )
  306. {
  307. return CloneEx( ppM, ((CItaMapping*)*ppM)->m_pFields, m_pFields, NULL, NULL, IISIMDB_INDEX_NB );
  308. }
  309. return FALSE;
  310. }
  311. public:
  312. private:
  313. LPSTR m_pFields[IISIMDB_INDEX_NB];
  314. } ;
  315. class CMd5Mapping : public CIisMapping {
  316. public:
  317. dllexp CMd5Mapping();
  318. dllexp CMd5Mapping( CIisAcctMapper* );
  319. dllexp ~CMd5Mapping();
  320. //
  321. BOOL Init( LPSTR pszRealm, LPSTR pszName, IISMDB_HEntry *pH, DWORD dwH );
  322. BOOL StoreFieldRef( DWORD iIndex, LPSTR pF ) { m_pFields[iIndex] = pF; return TRUE; }
  323. BOOL IsCrypt( DWORD iIndex ) { return (iIndex == IISMMDB_INDEX_IT_CLRPWD || iIndex == IISMMDB_INDEX_NT_PWD) ? TRUE : FALSE; }
  324. //
  325. UINT GetNbField(LPSTR **pF) { *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  326. UINT GetNbField(LPSTR **pF, LPDWORD *pC) { *pC = NULL; *pF = m_pFields; return sizeof(m_pFields)/sizeof(LPSTR);}
  327. dllexp BOOL MappingSetField( DWORD iIndex, LPSTR );
  328. BOOL Clone( CIisMapping** ppM)
  329. {
  330. if ( *ppM = new CMd5Mapping( m_pMapper ) )
  331. {
  332. return CloneEx( ppM, ((CMd5Mapping*)*ppM)->m_pFields, m_pFields, NULL, NULL, IISMMDB_INDEX_NB );
  333. }
  334. return FALSE;
  335. }
  336. public:
  337. private:
  338. LPSTR m_pFields[IISMMDB_INDEX_NB];
  339. } ;
  340. //
  341. // BLOB describing an issuer ( ASN.1 format )
  342. //
  343. typedef struct _IssuerAccepted {
  344. DWORD cbIssuerLen;
  345. LPBYTE pbIssuer;
  346. } IssuerAccepted;
  347. //
  348. // Mapping class descriptor ( a class defines the subset of fields used
  349. // to check for a mapping match ).
  350. //
  351. typedef struct _MappingClass {
  352. DWORD dwClass;
  353. DWORD dwFirst;
  354. DWORD dwLast;
  355. } MappingClass;
  356. class CIisAcctMapper {
  357. public:
  358. dllexp CIisAcctMapper();
  359. dllexp ~CIisAcctMapper();
  360. //
  361. // BOOL* updated with TRUE if 1st call to Init() for this object,
  362. // fMonitorChange used to indicate if change monitoring thread should
  363. // be created. If yes, changes to the database will trigger auto-refresh
  364. // This should be set to FALSE by the mapping Editor ( UI )
  365. //dllexp BOOL Init( BOOL*, BOOL fMonitorChange = TRUE );
  366. // fForce control whether instance is terminated even if non balanced
  367. // calls to Init()/Terminate()
  368. //dllexp BOOL Terminate( BOOL fForce = FALSE );
  369. // clear all mapping entries
  370. dllexp BOOL Reset();
  371. //DWORD UpdateIndication( VOID );
  372. virtual LPSTR GetRegKeyName() { return NULL; }
  373. //
  374. virtual BOOL LoadPrivate( FILE*, VALID_CTX ) { return TRUE; }
  375. virtual BOOL SavePrivate( FILE*, VALID_CTX ) { return TRUE; }
  376. virtual BOOL ResetPrivate() { return TRUE; }
  377. virtual IISMDB_HEntry* GetDefaultHierarchy( LPDWORD pdwN )
  378. { *pdwN = 0; return NULL; }
  379. //
  380. //
  381. dllexp void Lock();
  382. dllexp void Unlock();
  383. //
  384. dllexp BOOL FindMatch( CIisMapping* pQuery, CIisMapping** pResult, LPDWORD pI = NULL );
  385. dllexp BOOL UpdateClasses( BOOL fComputeMask = TRUE );
  386. BOOL SortMappings();
  387. public:
  388. //
  389. // to be used by DB clients
  390. //
  391. dllexp BOOL MappingGetFieldList(IISMDB_Fields** pF, DWORD* pC )
  392. { *pF = m_pFields; *pC = m_cFields; return TRUE; }
  393. dllexp DWORD GetOptions() { return m_dwOptions; }
  394. dllexp DWORD GetNbMapping( BOOL fAlt = FALSE ) { return (fAlt && m_pAltMapping) ? m_cAltMapping : m_cMapping; }
  395. dllexp BOOL GetMapping( DWORD iIndex, CIisMapping**, BOOL fFromAlt = FALSE, BOOL fPutAlt = FALSE );
  396. dllexp BOOL FlushAlternate( BOOL fApply );
  397. dllexp BOOL GetMappingForUpdate( DWORD iIndex, CIisMapping** );
  398. dllexp virtual CIisMapping* CreateNewMapping() { return NULL; }
  399. dllexp virtual BOOL Add( CIisMapping*, BOOL fAlternate = FALSE ); // release ownership of CIisMapping
  400. dllexp virtual DWORD AddEx( CIisMapping* ); // release ownership of CIisMapping
  401. dllexp BOOL Update( DWORD iIndex, CIisMapping* pM );
  402. dllexp BOOL Update( DWORD iIndex );
  403. dllexp BOOL Delete( DWORD iIndex, BOOL fUseAlternate = FALSE );
  404. dllexp VOID DeleteMappingObject( CIisMapping* pM );
  405. // can return ERROR_INVALID_ACCESS if MD5 signature invalid.
  406. // file was loaded anyway, must Save() to validate.
  407. dllexp BOOL Load();
  408. dllexp BOOL Save();
  409. dllexp IISMDB_HEntry* GetHierarchy( DWORD *pC ) { *pC = m_cHierarchy; return m_pHierarchy; }
  410. dllexp BOOL UpdateHierarchy() { return UpdateClasses( TRUE ); }
  411. //
  412. // Create unique ID for this object. Necessary before Load()/Save()
  413. //
  414. dllexp BOOL Create( VOID );
  415. dllexp BOOL Delete( VOID );
  416. dllexp BOOL Serialize( CStoreXBF* );
  417. dllexp BOOL Unserialize( CStoreXBF* );
  418. dllexp BOOL Unserialize( LPBYTE*, LPDWORD );
  419. dllexp BOOL Serialize( VOID );
  420. dllexp BOOL Unserialize( VOID );
  421. //
  422. dllexp virtual BOOL SetIssuerList( IssuerAccepted*, DWORD ) { return FALSE; }
  423. dllexp virtual BOOL GetIssuerList( IssuerAccepted**, DWORD* ) { return FALSE; }
  424. dllexp virtual BOOL DeleteIssuerList( IssuerAccepted*, DWORD ) { return FALSE; }
  425. dllexp virtual BOOL GetIssuerBuffer( LPBYTE, DWORD* ) { return FALSE; }
  426. dllexp virtual BOOL FreeIssuerBuffer( LPBYTE ) { return FALSE; }
  427. protected:
  428. CRITICAL_SECTION csLock;
  429. HANDLE m_hNotifyEvent;
  430. BOOL m_fRequestTerminate;
  431. LONG m_cInit;
  432. CIisMapping ** m_pMapping;
  433. DWORD m_cMapping;
  434. CIisMapping ** m_pAltMapping;
  435. DWORD m_cAltMapping;
  436. CHAR m_achFileName[MAX_PATH];
  437. IISMDB_HEntry * m_pHierarchy;
  438. DWORD m_cHierarchy;
  439. MappingClass* m_pClasses;
  440. IISMDB_Fields* m_pFields;
  441. DWORD m_cFields;
  442. DWORD m_dwOptions;
  443. MD5_CTX m_md5;
  444. LPBYTE m_pSesKey;
  445. DWORD m_dwSesKey;
  446. } ;
  447. //
  448. // SSL client certificates mapper
  449. //
  450. class CIisCertMapper : public CIisAcctMapper {
  451. public:
  452. dllexp CIisCertMapper();
  453. dllexp ~CIisCertMapper();
  454. LPSTR GetRegKeyName() { return IIS_CERT_MAPPER_REG; }
  455. IISMDB_HEntry* GetDefaultHierarchy( LPDWORD pdwN );
  456. dllexp CIisMapping* CreateNewMapping() { return (CIisMapping*)new CCertMapping(this); }
  457. #if defined(DECODE_ASN1)
  458. dllexp CIisMapping* CreateNewMapping( Cert_Map *pC );
  459. dllexp CIisMapping* CreateNewMapping( const LPBYTE pC, DWORD cC );
  460. #endif
  461. BOOL LoadPrivate( FILE*, VALID_CTX );
  462. BOOL SavePrivate( FILE*, VALID_CTX );
  463. BOOL ResetPrivate();
  464. //
  465. // copy the array of issuers to internal storage
  466. dllexp BOOL SetIssuerList( IssuerAccepted*, DWORD );
  467. // returns a copy of issuer list
  468. dllexp BOOL GetIssuerList( IssuerAccepted**, DWORD* );
  469. // used to delete the copy returned by GetIssuerList
  470. dllexp BOOL DeleteIssuerList( IssuerAccepted*, DWORD );
  471. dllexp virtual BOOL GetIssuerBuffer( LPBYTE, DWORD* );
  472. dllexp virtual BOOL FreeIssuerBuffer( LPBYTE );
  473. public:
  474. private:
  475. IssuerAccepted *m_pIssuers;
  476. DWORD m_cIssuers;
  477. } ;
  478. //
  479. // SSL client certificates 1:1 mapper
  480. //
  481. class CIisCert11Mapper : public CIisAcctMapper {
  482. public:
  483. dllexp CIisCert11Mapper();
  484. dllexp ~CIisCert11Mapper();
  485. LPSTR GetRegKeyName() { return IIS_CERT11_MAPPER_REG; }
  486. IISMDB_HEntry* GetDefaultHierarchy( LPDWORD pdwN );
  487. dllexp CIisMapping* CreateNewMapping() { return (CIisMapping*)new CCert11Mapping(this); }
  488. #if defined(CERT11_FULL_CERT)
  489. dllexp CIisMapping* CreateNewMapping( LPBYTE pC, DWORD dwC );
  490. #else
  491. dllexp CIisMapping* CreateNewMapping( LPBYTE pI, DWORD dwI, LPBYTE pS, DWORD dwB );
  492. #endif
  493. BOOL LoadPrivate( FILE*, VALID_CTX );
  494. BOOL SavePrivate( FILE*, VALID_CTX );
  495. BOOL ResetPrivate();
  496. BOOL Add( CIisMapping* );
  497. //
  498. // copy the array of issuers to internal storage
  499. dllexp BOOL SetIssuerList( IssuerAccepted*, DWORD );
  500. // returns a copy of issuer list
  501. dllexp BOOL GetIssuerList( IssuerAccepted**, DWORD* );
  502. // used to delete the copy returned by GetIssuerList
  503. dllexp BOOL DeleteIssuerList( IssuerAccepted*, DWORD );
  504. dllexp virtual BOOL GetIssuerBuffer( LPBYTE, DWORD* );
  505. dllexp virtual BOOL FreeIssuerBuffer( LPBYTE );
  506. //
  507. // Issuer + subject.field used as NT acct
  508. //
  509. dllexp BOOL SetSubjectSource( LPSTR );
  510. dllexp LPSTR GetSubjectSource() { return m_pSubjectSource; }
  511. dllexp BOOL SetDefaultDomain( LPSTR );
  512. dllexp LPSTR GetDefaultDomain() { return m_pDefaultDomain; }
  513. public:
  514. private:
  515. IssuerAccepted *m_pIssuers;
  516. DWORD m_cIssuers;
  517. LPSTR m_pSubjectSource;
  518. LPSTR m_pDefaultDomain;
  519. } ;
  520. //
  521. // Internet account mapper ( Basic authentication )
  522. //
  523. class CIisItaMapper : public CIisAcctMapper {
  524. public:
  525. dllexp CIisItaMapper();
  526. dllexp ~CIisItaMapper();
  527. LPSTR GetRegKeyName() { return IIS_ITA_MAPPER_REG; }
  528. IISMDB_HEntry* GetDefaultHierarchy( LPDWORD pdwN );
  529. dllexp CIisMapping* CreateNewMapping() { return (CIisMapping*)new CItaMapping(this); }
  530. dllexp CIisMapping* CreateNewMapping( LPSTR pszType, LPSTR pszName, LPSTR pszPdw );
  531. //
  532. public:
  533. private:
  534. } ;
  535. //
  536. // Digest authentication account mapper
  537. //
  538. class CIisMd5Mapper : public CIisAcctMapper {
  539. public:
  540. dllexp CIisMd5Mapper();
  541. dllexp ~CIisMd5Mapper();
  542. LPSTR GetRegKeyName() { return IIS_MD5_MAPPER_REG; }
  543. IISMDB_HEntry* GetDefaultHierarchy( LPDWORD pdwN );
  544. dllexp CIisMapping* CreateNewMapping() { return (CIisMapping*)new CMd5Mapping(this); }
  545. dllexp CIisMapping* CreateNewMapping( LPSTR pszRealm, LPSTR pszName );
  546. //
  547. public:
  548. private:
  549. } ;
  550. dllexp
  551. BOOL
  552. ReportIisMapEvent(
  553. WORD wType,
  554. DWORD dwEventId,
  555. WORD cNbStr,
  556. LPCTSTR* pStr
  557. );
  558. dllexp
  559. BOOL IISuudecode(char * bufcoded,
  560. BYTE * bufout,
  561. DWORD * pcbDecoded,
  562. BOOL fBase64
  563. );
  564. dllexp
  565. BOOL IISuuencode( BYTE * bufin,
  566. DWORD nbytes,
  567. BYTE * outptr,
  568. BOOL fBase64 );
  569. dllexp
  570. DWORD WINAPI
  571. CreateMapping(
  572. LPWSTR pwszUuIssuer,
  573. LPWSTR pwszUuSubject,
  574. LPWSTR pwszNtAcct
  575. );
  576. dllexp
  577. DWORD WINAPI
  578. CheckMapping(
  579. LPWSTR pwszUuIssuer,
  580. LPWSTR pwszUuSubject,
  581. LPWSTR* pwszNtAcct
  582. );
  583. dllexp
  584. DWORD WINAPI
  585. SaveMapping(
  586. VOID
  587. );
  588. BOOL InitializeMapping( HANDLE );
  589. VOID TerminateMapping();
  590. BOOL
  591. LoadFieldNames(
  592. IISMDB_Fields* pFields,
  593. UINT cFields
  594. );
  595. VOID
  596. FreeFieldNames(
  597. IISMDB_Fields* pFields,
  598. UINT cFields
  599. );
  600. dllexp VOID
  601. FreeCIisAcctMapper(
  602. LPVOID pMapper
  603. );