00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00037 #ifndef _UNIXREQUEST_H
00038 #define _UNIXREQUEST_H
00039
00040 #include<stdarg.h>
00041
00042 #ifdef _WIN32
00043 # include "Certsrv.h"
00044 #endif//_WIN32
00045 #ifdef UNIX
00046 # include "CSP_WinCrypt.h"
00047 #ifndef VARIANT
00048 # define VARIANT void*
00049 #endif//VARIANT
00050 #endif // UNIX
00051
00052 #include "SecureBuffer.h"
00053
00054 #include "BSTR.h"
00055 #include <vector>
00056 #include <string>
00057 #include "reader/support.h"
00058 #include <map>
00059
00060 #ifndef _WIN32
00061 typedef unsigned short VARIANT_BOOL;
00062 #endif//_WIN32
00063
00064
00065
00066
00067
00068
00069 #define PROPTYPE_LONG 0x00000001 // Signed long
00070 #define PROPTYPE_DATE 0x00000002 // Date+Time
00071 #define PROPTYPE_BINARY 0x00000003 // Binary data
00072 #define PROPTYPE_STRING 0x00000004 // Unicode String
00073 #define PROPTYPE_MASK 0x000000ff
00074
00075
00076
00077
00078 #define CR_IN_BASE64HEADER ( 0 )
00079 #define CR_IN_BASE64 ( 0x1 )
00080
00081
00082 #define CR_IN_ENCODEMASK ( 0xff )
00083
00084 #define CR_IN_PKCS10 ( 0x100 )
00085
00086
00087
00088 #define CR_IN_FORMATMASK ( 0xff00 )
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 #define CR_DISP_INCOMPLETE ( 0 )
00099 #define CR_DISP_ERROR ( 0x1 )
00100 #define CR_DISP_DENIED ( 0x2 )
00101 #define CR_DISP_ISSUED ( 0x3 )
00102 #define CR_DISP_ISSUED_OUT_OF_BAND ( 0x4 )
00103 #define CR_DISP_UNDER_SUBMISSION ( 0x5 )
00104 #define CR_DISP_REVOKED ( 0x6 )
00105
00106 #define CR_OUT_BASE64HEADER ( 0 )
00107 #define CR_OUT_BASE64 ( 0x1 )
00108 #define CR_OUT_BINARY ( 0x2 )
00109 #define CR_OUT_BASE64REQUESTHEADER ( 0x3 )
00110
00111
00112 #define CR_OUT_BASE64X509CRLHEADER ( 0x9 )
00113
00114
00115
00116 #define CR_OUT_ENCODEMASK ( 0xff )
00117 #define CR_OUT_CHAIN ( 0x100 )
00118 #define CR_OUT_CRLS ( 0x200 )
00119
00120
00121 #define CR_UNKNOWN_ERR ( -1 )
00122 #define CR_WRONG_PASS ( -2 )
00123 #define CR_OLD_MARKER ( -3 )
00124 #define CR_NOT_EXIST_MARKER ( -4 )
00125 #define CR_WRONG_MARKER_NAME ( -5 )
00126
00127 #define CR_PROP_NONE 0 // Invalid
00128
00129
00130
00131
00133
00134
00135
00136
00137
00138
00139
00140
00141 #define CR_PROP_CASIGCERTCOUNT 11 // Long
00142
00143
00144 #define CR_PROP_CASIGCERT 12 // Binary, Indexed
00145
00146
00147 #define CR_PROP_CASIGCERTCHAIN 13 // Binary, Indexed
00148
00149
00150
00152
00153
00155
00156
00157
00158
00159
00160 #define CR_PROP_BASECRL 17 // Binary, Indexed
00161
00162
00163
00164
00165 #define CR_PROP_DELTACRL 18 // Binary, Indexed
00166
00168
00169
00170
00171 #define CR_PROP_CRLSTATE 20 // Long, Indexed
00172
00173
00174
00175
00176
00177
00178
00180
00181
00183
00184
00185
00186 #define CR_PROP_TEMPLATES 29 // String
00187
00190
00191
00193
00194
00195
00196
00197 #define CR_PROP_CASIGCERTCRLCHAIN 32 // Binary, Indexed
00198
00200
00201
00203
00204
00206
00207
00209
00210
00212
00213
00215
00216
00218
00219
00220
00222
00223
00225
00226
00228
00229
00231
00232
00233 #define CR_PROP_TEMPLATES_CA20 300 // String
00234
00235
00236
00237
00238 #define CV_OUT_BASE64HEADER ( 0 )
00239 #define CV_OUT_BASE64 ( 0x1 )
00240
00241 #define CV_OUT_BASE64REQUESTHEADER ( 0x3 )
00242
00243
00244 #define CV_OUT_BASE64X509CRLHEADER ( 0x9 )
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 #define CR_OUT_HTML ( 0xc3 )
00256
00257
00258
00259
00263 #ifndef _WIN32
00264 typedef
00265 enum X509EnrollmentAuthFlags
00266 {
00267 X509AuthNone = 0,
00268 X509AuthAnonymous = 1,
00269 X509AuthKerberos = 2,
00270 X509AuthUsername = 4,
00271 X509AuthCertificate = 8
00272 } X509EnrollmentAuthFlags;
00273 #endif//_WIN32
00274
00275
00276
00282 typedef
00283 enum X509EnrollmentCheckChainFlags
00284 {
00285 X509CC_None = 0,
00286 X509CC_TLS = 1,
00287 X509CC_NoHostNameCheck= 2,
00289 X509CC_NoCheck = 4
00291 } X509EnrollmentCheckChainFlags;
00292
00301 class UnixRequest
00302 {
00303 public:
00304
00314 static UnixRequest *URFactory(const char *pszCA_type_name);
00315
00321 class UserCallbacks
00322 {
00323 public:
00339 virtual bool askCredentialCAThumbprint(
00340 const BSTR prompt,
00341 BSTR *strCredentialCAThumbprint){
00342 UNUSED(prompt);
00343 UNUSED(strCredentialCAThumbprint);
00344 return false;
00345 }
00346
00360 virtual bool showForCheckCAThumbprint(
00361 const BSTR prompt,
00362 const BSTR strCAThumbprint){
00363 UNUSED(prompt);
00364 UNUSED(strCAThumbprint);
00365 return false;
00366 }
00367
00379 virtual bool askPassword(
00380 const BSTR prompt,
00381 CSecurePin &password){
00382 UNUSED(prompt);
00383 UNUSED(password);
00384 return false;
00385 }
00386
00390 virtual UserCallbacks* clone() const=0;
00391
00395 virtual ~UserCallbacks() {}
00396 };
00397
00398 virtual ~UnixRequest() {}
00399
00427 virtual HRESULT SetCredential(
00428 UserCallbacks *pCallbacks,
00429 X509EnrollmentAuthFlags AuthType,
00430 X509EnrollmentCheckChainFlags CheckChainType,
00431 const BSTR strCredential,
00432 CSecurePin *sbPassword,
00433 BOOL UseLocalMachineCert = FALSE) = 0;
00434
00435 class AttrTriple
00436 {
00437 public:
00438 LONG Flags;
00439 BSTR Name;
00440 BSTR Value;
00441
00442 AttrTriple():Flags(0),Name(0),Value(0) { };
00443 ~AttrTriple()
00444 {
00445 if (Name)
00446 SysFreeString(Name);
00447 if (Value)
00448 SysFreeString(Value);
00449 };
00450 };
00451
00452 class RequestInfoEx
00453 {
00454 bool has_items;
00455 public:
00456 LONG Disposition;
00457 std::string sent_date;
00458 std::string approval_date;
00459 std::string comment;
00460 std::string PKCS;
00461 RequestInfoEx():has_items(false),Disposition(-1),
00462 sent_date(),approval_date(),comment(),PKCS()
00463 {
00464 };
00465 RequestInfoEx(
00466 LONG Disposition_,
00467 const std::string & sent_date_,
00468 const std::string & approval_date_,
00469 const std::string & comment_,
00470 const std::string & PKCS_
00471 ): has_items(true),
00472 Disposition(Disposition_),
00473 sent_date(sent_date_),
00474 approval_date(approval_date_),
00475 comment(comment_),
00476 PKCS(PKCS_)
00477 {
00478 };
00479 bool empty()
00480 {
00481 return !has_items;
00482 };
00483 };
00484
00485 typedef enum
00486 {
00487 CA15None=0,
00488 CA15Cert=1,
00489 CA15Request=2,
00490 CA15Revoke=3
00491 } ReqType;
00492
00493 typedef std::map<std::string,RequestInfoEx> RequestMapEx;
00494
00514 virtual HRESULT GetRequestParams(
00515 BSTR strConfig,
00516 BSTR strTemplate,
00517 BSTR *pstrRDN,
00518 BSTR *pstrEKUsage,
00519 DWORD *pKeySpec,
00520 std::vector<AttrTriple> *pAttrs
00521 ){
00522 UNUSED(strConfig);
00523 UNUSED(strTemplate);
00524 UNUSED(pstrRDN);
00525 UNUSED(pstrEKUsage);
00526 UNUSED(pKeySpec);
00527 UNUSED(pAttrs);
00528 return E_NOTIMPL;
00529 }
00530
00536 typedef std::map<std::string,LONG> RequestMap;
00537
00538 virtual HRESULT ListRequests(
00539 BSTR strConfig,
00540 RequestMap &Requests
00541 ) {
00542 UNUSED(strConfig);
00543 UNUSED(Requests);
00544 return E_NOTIMPL;
00545 }
00553 virtual HRESULT ListRequestsEx(
00554 BSTR strConfig,
00555 RequestMapEx & Requests,
00556 ReqType type = CA15Request
00557 ) {
00558 UNUSED(strConfig);
00559 UNUSED(Requests);
00560 UNUSED(type);
00561 return E_NOTIMPL;
00562 }
00563
00576 virtual HRESULT GetRequest(
00577 LONG Flags,
00578 BSTR *pstrRequest){
00579 UNUSED(Flags);
00580 UNUSED(pstrRequest);
00581 return E_NOTIMPL;
00582 }
00583
00584 public:
00585
00613 virtual HRESULT Submit(
00614 LONG Flags,
00615 const BSTR strRequest,
00616 const BSTR strAttributes,
00617 const BSTR strConfig,
00618 LONG *pDisposition) = 0;
00619
00651 virtual HRESULT RetrievePending(
00652 LONG RequestId,
00653 const BSTR strConfig,
00654 LONG *pDisposition) = 0;
00655
00683 virtual HRESULT AcknowledgeInstallCert(
00684 LONG RequestId,
00685 const BSTR strConfig
00686 )
00687 {
00688 UNUSED(RequestId);
00689 UNUSED(strConfig);
00690 return E_NOTIMPL;
00691 }
00692
00693
00694
00708 virtual HRESULT GetLastStatus(
00709 LONG *pStatus) {
00710 UNUSED(pStatus);
00711 return E_NOTIMPL;
00712 }
00713
00721 virtual HRESULT GetRequestId(
00722 LONG *pRequestId) = 0;
00723
00735 virtual HRESULT GetDispositionMessage(
00736 BSTR *pstrDispositionMessage) = 0;
00737
00755 virtual HRESULT GetCACertificate(
00756 LONG fExchangeCertificate,
00757 const BSTR strConfig,
00758 LONG Flags,
00759 BSTR *pstrCertificate) = 0;
00760
00772 virtual HRESULT GetCertificate(
00773 LONG Flags,
00774 BSTR *pstrCertificate) = 0;
00775
00776 public:
00777
00813 virtual HRESULT GetIssuedCertificate(
00814 const BSTR strConfig,
00815 LONG RequestId,
00816 const BSTR strSerialNumber,
00817 LONG *pDisposition){
00818 UNUSED(strConfig);
00819 UNUSED(RequestId);
00820 UNUSED(strSerialNumber);
00821 UNUSED(pDisposition);
00822 return E_NOTIMPL;
00823 }
00824
00843 virtual HRESULT GetErrorMessageText(
00844 LONG hrMessage,
00845 LONG Flags,
00846 BSTR *pstrErrorMessageText){
00847 UNUSED(hrMessage);
00848 UNUSED(Flags);
00849 UNUSED(pstrErrorMessageText);
00850 return E_NOTIMPL;
00851 }
00861 virtual HRESULT RegisterUser(
00862 BSTR bstrConfig,
00863 void * pUserInfo
00864 )
00865 {
00866 UNUSED(bstrConfig);
00867 UNUSED(pUserInfo);
00868 return E_NOTIMPL;
00869 }
00879 virtual HRESULT GetUserRegisterInfo(
00880 BSTR bstrConfig,
00881 void * pUserInfo
00882 )
00883 {
00884 UNUSED(bstrConfig);
00885 UNUSED(pUserInfo);
00886 return E_NOTIMPL;
00887 }
00888
00904 virtual HRESULT GetUserRegisterStatus(
00905 BSTR bstrConfig,
00906 LONG * pUserRegisterId,
00907 LONG * pUserRegisterStatus
00908 )
00909 {
00910 UNUSED(bstrConfig);
00911 UNUSED(pUserRegisterId);
00912 UNUSED(pUserRegisterStatus);
00913 return E_NOTIMPL;
00914 }
00915
00916
00948 virtual HRESULT GetCAProperty(
00949 const BSTR strConfig,
00950 LONG PropId,
00951 LONG PropIndex,
00952 LONG PropType,
00953 LONG Flags,
00954 VARIANT *pvarPropertyValue) = 0;
00955
00969 virtual HRESULT GetCAPropertyFlags(
00970 const BSTR strConfig,
00971 LONG PropId,
00972 LONG *pPropFlags){
00973 UNUSED(strConfig);
00974 UNUSED(PropId);
00975 UNUSED(pPropFlags);
00976 return E_NOTIMPL;
00977 }
00978
00992 virtual HRESULT GetCAPropertyDisplayName(
00993 const BSTR strConfig,
00994 LONG PropId,
00995 BSTR *pstrDisplayName){
00996 UNUSED(strConfig);
00997 UNUSED(PropId);
00998 UNUSED(pstrDisplayName);
00999 return E_NOTIMPL;
01000 }
01001
01018 virtual HRESULT GetFullResponseProperty(
01019 LONG PropId,
01020 LONG PropIndex,
01021 LONG PropType,
01022 LONG Flags,
01023 VARIANT *pvarPropertyValue){
01024 UNUSED(PropId);
01025 UNUSED(PropIndex);
01026 UNUSED(PropType);
01027 UNUSED(Flags);
01028 UNUSED(pvarPropertyValue);
01029 return E_NOTIMPL;
01030 }
01031
01032 public:
01033
01055 virtual HRESULT SetCredential(
01056 LONG hWnd,
01057 X509EnrollmentAuthFlags AuthType,
01058 BSTR strCredential,
01059 BSTR strPassword) = 0;
01072 virtual HRESULT GetRequestIdString(
01073 BSTR *pstrRequestId){
01074 UNUSED(pstrRequestId);
01075 return E_NOTIMPL;
01076 }
01077
01117 virtual HRESULT GetIssuedCertificate2(
01118 BSTR strConfig,
01119 BSTR strRequestId,
01120 BSTR strSerialNumber,
01121 LONG *pDisposition){
01122 UNUSED(strConfig);
01123 UNUSED(strRequestId);
01124 UNUSED(strSerialNumber);
01125 UNUSED(pDisposition);
01126 return E_NOTIMPL;
01127 }
01128
01139 virtual HRESULT GetRefreshPolicy(
01140 VARIANT_BOOL *pValue){
01141 UNUSED(pValue);
01142 return E_NOTIMPL;
01143 }
01144
01145 };
01146 #endif