Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / security / impl / OpenSSLCryptoX509CRL.cpp
index 74dfd3e..9e1e821 100644 (file)
@@ -1,23 +1,27 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
  * OpenSSLCryptoX509CRL.cpp
  * 
- * OpenSSL-based class for handling X.509 CRLs
+ * OpenSSL-based class for handling X.509 CRLs.
  */
 
 #include "internal.h"
@@ -34,6 +38,10 @@ XSEC_USING_XERCES(Janitor);
 
 using namespace xmltooling;
 
+OpenSSLCryptoX509CRL::OpenSSLCryptoX509CRL() : mp_X509CRL(nullptr), m_DERX509CRL("")
+{
+}
+
 OpenSSLCryptoX509CRL::~OpenSSLCryptoX509CRL()
 {
        if (mp_X509CRL)
@@ -73,7 +81,13 @@ OpenSSLCryptoX509CRL::OpenSSLCryptoX509CRL(X509_CRL* x) {
        BIO_free_all(b64);
 }
 
-void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int len) {
+const XMLCh* OpenSSLCryptoX509CRL::getProviderName() const
+{
+    return DSIGConstants::s_unicodeStrPROVOpenSSL;
+}
+
+void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int len)
+{
 
        // Free anything currently held.
        
@@ -95,14 +109,14 @@ void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int le
 
        if (bufLen > 0) {
 #if defined(XSEC_OPENSSL_D2IX509_CONST_BUFFER)
-               mp_X509CRL=  d2i_X509_CRL(NULL, (const unsigned char **) (&outBuf), bufLen);
+               mp_X509CRL=  d2i_X509_CRL(nullptr, (const unsigned char **) (&outBuf), bufLen);
 #else
-               mp_X509CRL=  d2i_X509_CRL(NULL, &outBuf, bufLen);
+               mp_X509CRL=  d2i_X509_CRL(nullptr, &outBuf, bufLen);
 #endif
        }
 
        // Check to see if we have a CRL....
-       if (mp_X509CRL == NULL) {
+       if (mp_X509CRL == nullptr) {
                throw XSECCryptoException(XSECCryptoException::X509Error,
                "OpenSSL:X509CRL - Error translating Base64 DER encoding into OpenSSL X509 CRL structure");
        }
@@ -110,3 +124,21 @@ void OpenSSLCryptoX509CRL::loadX509CRLBase64Bin(const char* buf, unsigned int le
        m_DERX509CRL.sbStrcpyIn(buf);
 
 }
+
+safeBuffer& OpenSSLCryptoX509CRL::getDEREncodingSB()
+{
+    return m_DERX509CRL;
+}
+
+X509_CRL* OpenSSLCryptoX509CRL::getOpenSSLX509CRL()
+{
+    return mp_X509CRL;
+}
+
+XSECCryptoX509CRL* OpenSSLCryptoX509CRL::clone() const
+{
+    OpenSSLCryptoX509CRL* copy = new OpenSSLCryptoX509CRL();
+    copy->mp_X509CRL = X509_CRL_dup(mp_X509CRL);
+    copy->m_DERX509CRL = m_DERX509CRL;
+    return copy;
+}