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