Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / security / X509Credential.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file xmltooling/security/X509Credential.h
23  * 
24  * Wraps an X.509-based Credential. 
25  */
26
27 #if !defined(__xmltooling_x509cred_h__) && !defined(XMLTOOLING_NO_XMLSEC)
28 #define __xmltooling_x509cred_h__
29
30 #include <xmltooling/security/Credential.h>
31
32 class XSECCryptoX509;
33
34 namespace xmltooling {
35
36     class XMLTOOL_API XSECCryptoX509CRL;
37
38     /**
39      * Wraps an X.509-based Credential.
40      */
41     class XMLTOOL_API X509Credential : public virtual Credential
42     {
43     protected:
44         X509Credential();
45         
46     public:
47         virtual ~X509Credential();
48
49         /**
50          * Bitmask constants for limiting resolution process inside a CredentialResolver. 
51          */
52         enum ResolveTypes {
53             RESOLVE_CERTS = 4,
54             RESOLVE_CRLS = 8
55         };
56
57         /**
58          * Bitmask of supported KeyInfo content to generate. 
59          */
60         enum KeyInfoTypes {
61             KEYINFO_X509_CERTIFICATE = 4,
62             KEYINFO_X509_SUBJECTNAME = 8,
63             KEYINFO_X509_ISSUERSERIAL = 16,
64             KEYINFO_X509_DIGEST = 32
65         };
66
67         /**
68          * Gets an immutable collection of certificates in the entity's trust chain. The entity certificate is contained
69          * within this list. No specific ordering of the certificates is guaranteed.
70          * 
71          * @return a certificate chain
72          */
73         virtual const std::vector<XSECCryptoX509*>& getEntityCertificateChain() const=0;
74
75         /**
76          * @deprecated
77          *
78          * Gets a CRL associated with the credential.
79          * 
80          * @return CRL associated with the credential
81          */
82         virtual XSECCryptoX509CRL* getCRL() const=0;
83
84         /**
85          * Gets an immutable collection of all CRLs associated with the credential.
86          * 
87          * @return CRLs associated with the credential
88          */
89         virtual const std::vector<XSECCryptoX509CRL*>& getCRLs() const=0;
90
91
92         /**
93          * Gets the subject name of the first certificate in the chain.
94          *
95          * @return the Subject DN
96          */
97         virtual const char* getSubjectName() const=0;
98
99         /**
100          * Gets the issuer name of the first certificate in the chain.
101          *
102          * @return the Issuer DN
103          */
104         virtual const char* getIssuerName() const=0;
105
106         /**
107          * Gets the serial number of the first certificate in the chain.
108          *
109          * @return the serial number
110          */
111         virtual const char* getSerialNumber() const=0;
112
113         /**
114          * Extracts properties like issuer and subject from the first certificate in the chain.
115          */
116         virtual void extract()=0;
117     };
118 };
119
120 #endif /* __xmltooling_x509cred_h__ */