1 | /* $Id: CertificateImpl.h 60243 2016-03-29 14:21:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM ICertificate implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_CERTIFICATEIMPL
|
---|
19 | #define ____H_CERTIFICATEIMPL
|
---|
20 |
|
---|
21 | //#define DONT_DUPLICATE_ALL_THE_DATA
|
---|
22 |
|
---|
23 | /* VBox includes */
|
---|
24 | #include <VBox/settings.h>
|
---|
25 | #include <iprt/crypto/x509.h>
|
---|
26 | #include "CertificateWrap.h"
|
---|
27 |
|
---|
28 | #include <vector>
|
---|
29 |
|
---|
30 |
|
---|
31 | using namespace std;
|
---|
32 |
|
---|
33 | #ifndef DONT_DUPLICATE_ALL_THE_DATA
|
---|
34 | /* VBox forward declarations */
|
---|
35 | class Appliance;
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | class ATL_NO_VTABLE Certificate :
|
---|
39 | public CertificateWrap
|
---|
40 | {
|
---|
41 |
|
---|
42 | public:
|
---|
43 |
|
---|
44 | DECLARE_EMPTY_CTOR_DTOR(Certificate)
|
---|
45 |
|
---|
46 | #ifdef DONT_DUPLICATE_ALL_THE_DATA
|
---|
47 | HRESULT init(PCRTCRX509CERTIFICATE a_pCert);
|
---|
48 | #else
|
---|
49 | HRESULT init(Appliance* appliance);
|
---|
50 | #endif
|
---|
51 | void uninit();
|
---|
52 |
|
---|
53 | HRESULT FinalConstruct();
|
---|
54 | void FinalRelease();
|
---|
55 |
|
---|
56 | #ifndef DONT_DUPLICATE_ALL_THE_DATA
|
---|
57 | HRESULT setData(RTCRX509CERTIFICATE const *inCert);
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | private:
|
---|
61 | #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */
|
---|
62 | const Appliance* m_appliance;
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */
|
---|
66 | HRESULT setVersionNumber(uint64_t inVersionNumber);
|
---|
67 | HRESULT setSerialNumber(uint64_t inSerialNumber);
|
---|
68 | HRESULT setPublicKeyAlgorithmOID(const char *aPublicKeyAlgorithmOID);
|
---|
69 | HRESULT setPublicKeyAlgorithmName(const char *aPublicKeyAlgorithmOID);
|
---|
70 | HRESULT setSignatureAlgorithmOID(const char *aSignatureAlgorithmOID);
|
---|
71 | HRESULT setSignatureAlgorithmName(const char *aSignatureAlgorithmOID);
|
---|
72 | HRESULT setIssuerName(com::Utf8Str &aIssuerName);
|
---|
73 | HRESULT setSubjectName(com::Utf8Str &aSubjectName);
|
---|
74 | HRESULT setValidityPeriodNotBefore(PCRTTIME aValidityPeriodNotBefore);
|
---|
75 | HRESULT setValidityPeriodNotAfter(PCRTTIME aValidityPeriodNotAfter);
|
---|
76 | HRESULT setCertificateAuthority(BOOL aCertificateAuthority);
|
---|
77 | HRESULT setSelfSigned(BOOL aSelfSigned);
|
---|
78 | HRESULT setTrusted(BOOL aTrusted);
|
---|
79 | // HRESULT setSubjectPublicKey(std::vector<BYTE> aSubjectPublicKey);
|
---|
80 | // HRESULT setIssuerUniqueIdentifier(std::vector<BYTE> aIssuerUniqueIdentifier);
|
---|
81 | // HRESULT setSubjectUniqueIdentifier(std::vector<BYTE> aSubjectUniqueIdentifier);
|
---|
82 | // HRESULT setKeyUsage(std::vector<ULONG> aKeyUsage);
|
---|
83 | // HRESULT setExtendedKeyUsage(std::vector<com::Utf8Str> aExtendedKeyUsage);
|
---|
84 | // HRESULT setRawCertData(std::vector<BYTE> aRawCertData);
|
---|
85 | #endif
|
---|
86 |
|
---|
87 | // wrapped ICertificate properties
|
---|
88 | HRESULT getVersionNumber(com::Utf8Str &aVersionNumber);
|
---|
89 | HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
|
---|
90 | HRESULT getSignatureAlgorithmOID(com::Utf8Str &aSignatureAlgorithmOID);
|
---|
91 | HRESULT getSignatureAlgorithmName(com::Utf8Str &aSignatureAlgorithmName);
|
---|
92 | HRESULT getPublicKeyAlgorithmOID(com::Utf8Str &aPublicKeyAlgorithmOID);
|
---|
93 | HRESULT getPublicKeyAlgorithm(com::Utf8Str &aPublicKeyAlgorithm);
|
---|
94 | HRESULT getIssuerName(std::vector<com::Utf8Str> &aIssuerName);
|
---|
95 | HRESULT getSubjectName(std::vector<com::Utf8Str> &aSubjectName);
|
---|
96 | HRESULT getValidityPeriodNotBefore(com::Utf8Str &aValidityPeriodNotBefore);
|
---|
97 | HRESULT getValidityPeriodNotAfter(com::Utf8Str &aValidityPeriodNotAfter);
|
---|
98 | HRESULT getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey);
|
---|
99 | HRESULT getIssuerUniqueIdentifier(com::Utf8Str &aIssuerUniqueIdentifier);
|
---|
100 | HRESULT getSubjectUniqueIdentifier(com::Utf8Str &aSubjectUniqueIdentifier);
|
---|
101 | HRESULT getCertificateAuthority(BOOL *aCertificateAuthority);
|
---|
102 | HRESULT getKeyUsage(ULONG *aKeyUsage);
|
---|
103 | HRESULT getExtendedKeyUsage(std::vector<com::Utf8Str> &aExtendedKeyUsage);
|
---|
104 | HRESULT getRawCertData(std::vector<BYTE> &aRawCertData);
|
---|
105 | HRESULT getSelfSigned(BOOL *aSelfSigned);
|
---|
106 | HRESULT getTrusted(BOOL *aTrusted);
|
---|
107 |
|
---|
108 | // wrapped ICertificate methods
|
---|
109 | HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult);
|
---|
110 | #ifndef DONT_DUPLICATE_ALL_THE_DATA
|
---|
111 | HRESULT checkExistence(BOOL *aPresence);
|
---|
112 | HRESULT isVerified(BOOL *aVerified);
|
---|
113 | #endif
|
---|
114 |
|
---|
115 | #ifdef DONT_DUPLICATE_ALL_THE_DATA
|
---|
116 | /** @name Methods extracting COM data from the certificate object
|
---|
117 | * @{ */
|
---|
118 | HRESULT i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn);
|
---|
119 | HRESULT i_getX509Name(PCRTCRX509NAME a_pName, std::vector<com::Utf8Str> &a_rReturn);
|
---|
120 | HRESULT i_getTime(PCRTASN1TIME a_pTime, com::Utf8Str &a_rReturn);
|
---|
121 | HRESULT i_getUniqueIdentifier(PCRTCRX509UNIQUEIDENTIFIER a_pUniqueId, com::Utf8Str &a_rReturn);
|
---|
122 | HRESULT i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn);
|
---|
123 | /** @} */
|
---|
124 | #endif
|
---|
125 | //data
|
---|
126 | struct Data;
|
---|
127 | Data *mData;
|
---|
128 |
|
---|
129 | };
|
---|
130 |
|
---|
131 | #endif // !____H_CERTIFICATEIMPL
|
---|
132 |
|
---|