Update copyright.
[shibboleth/cpp-xmltooling.git] / xmltooling / security / OpenSSLCryptoX509CRL.h
1 /*
2  * Copyright 2001-2007 The Apache Software Foundation.
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  * OpenSSLCryptoX509CRL.h
19  * 
20  * OpenSSL-based class for handling X.509 CRLs
21  */
22
23 #if !defined(__xmltooling_opensslx509crl_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_opensslx509crl_h__
25
26 #include <xmltooling/security/XSECCryptoX509CRL.h>
27
28 #include <openssl/bio.h>
29 #include <openssl/x509v3.h>
30 #include <xsec/utils/XSECSafeBuffer.hpp>
31
32 namespace xmltooling {
33     /**
34      * OpenSSL-based class for handling X.509 CRLs
35      */
36     class XMLTOOL_API OpenSSLCryptoX509CRL : public XSECCryptoX509CRL {
37     public:
38         OpenSSLCryptoX509CRL() : mp_X509CRL(NULL), m_DERX509CRL("") {}
39         virtual ~OpenSSLCryptoX509CRL();
40
41         virtual const XMLCh* getProviderName() const {
42             return DSIGConstants::s_unicodeStrPROVOpenSSL;
43         }
44         virtual void loadX509CRLBase64Bin(const char* buf, unsigned int len);
45     
46         virtual safeBuffer& getDEREncodingSB(void) {
47             return m_DERX509CRL;
48         }
49     
50         /**
51          * Constructor
52          * 
53          * @param x a native CRL object
54          */
55         OpenSSLCryptoX509CRL(X509_CRL* x);
56         
57         /**
58          * Returns native CRL object.
59          * 
60          * @return  native CRL object, or NULL
61          */
62         X509_CRL* getOpenSSLX509CRL() {
63             return mp_X509CRL;
64         }
65
66         XSECCryptoX509CRL* clone() const {
67             OpenSSLCryptoX509CRL* copy = new OpenSSLCryptoX509CRL();
68             copy->mp_X509CRL = X509_CRL_dup(mp_X509CRL);
69             copy->m_DERX509CRL = m_DERX509CRL;
70             return copy;
71         }
72     
73     private:
74         X509_CRL* mp_X509CRL;
75         safeBuffer m_DERX509CRL;
76     };
77 };
78
79 #endif /* __xmltooling_opensslx509crl_h__ */
80