summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-07-28 10:13:45 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-07-28 12:37:12 +0100
commit1ebd5de9de4291e7b5cbaaa912f5b4524c14ad81 (patch)
tree296f56aad80c5225c2e914c1cd2782e856ef0c86
parentb073ef93313f9e07f9f8b7bf65dc74721b15da6c (diff)
Related: tdf#95144 now merge common code into a shared CertExtn struct
Change-Id: I7514e092e4314d7cadee33df0e964362777b0b83
-rw-r--r--xmlsecurity/Library_xsec_xmlsec.mk2
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_certextn.cxx (renamed from xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx)44
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_certextn.hxx38
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx36
-rw-r--r--xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx52
-rw-r--r--xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx28
6 files changed, 91 insertions, 109 deletions
diff --git a/xmlsecurity/Library_xsec_xmlsec.mk b/xmlsecurity/Library_xsec_xmlsec.mk
index 65b3cfc6582c..978f7ad26a6d 100644
--- a/xmlsecurity/Library_xsec_xmlsec.mk
+++ b/xmlsecurity/Library_xsec_xmlsec.mk
@@ -56,7 +56,7 @@ $(eval $(call gb_Library_use_externals,xsec_xmlsec,\
$(eval $(call gb_Library_add_exception_objects,xsec_xmlsec,\
xmlsecurity/source/xmlsec/biginteger \
- xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl \
+ xmlsecurity/source/xmlsec/certificateextension_certextn \
xmlsecurity/source/xmlsec/errorcallback \
xmlsecurity/source/xmlsec/saxhelper \
xmlsecurity/source/xmlsec/serialnumberadapter \
diff --git a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx
index c62648f120f6..3c333d2ed64d 100644
--- a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.cxx
+++ b/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx
@@ -17,59 +17,35 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sal/config.h>
-#include <rtl/uuid.h>
+#include "certificateextension_certextn.hxx"
-#include "certificateextension_xmlsecimpl.hxx"
-
-using namespace ::com::sun::star::uno ;
-
-using ::com::sun::star::security::XCertificateExtension ;
-
-CertificateExtension_XmlSecImpl::CertificateExtension_XmlSecImpl() :
- m_critical( false ) ,
- m_xExtnId() ,
- m_xExtnValue()
+CertificateExtension_CertExtn::CertificateExtension_CertExtn()
+ : m_critical(false)
{
}
-CertificateExtension_XmlSecImpl::~CertificateExtension_XmlSecImpl() {
-}
-
-
-//Methods from XCertificateExtension
-sal_Bool SAL_CALL CertificateExtension_XmlSecImpl::isCritical() throw( css::uno::RuntimeException, std::exception ) {
- return m_critical ;
-}
-
-css::uno::Sequence< sal_Int8 > SAL_CALL CertificateExtension_XmlSecImpl::getExtensionId() throw( css::uno::RuntimeException, std::exception ) {
- return m_xExtnId ;
-}
-
-css::uno::Sequence< sal_Int8 > SAL_CALL CertificateExtension_XmlSecImpl::getExtensionValue() throw( css::uno::RuntimeException, std::exception ) {
- return m_xExtnValue ;
-}
-
-void CertificateExtension_XmlSecImpl::setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical ) {
+void CertificateExtension_CertExtn::setCertExtn(unsigned char* value, unsigned int vlen,
+ unsigned char* id, unsigned int idlen, bool critical)
+{
unsigned int i ;
if( value != nullptr && vlen != 0 ) {
- Sequence< sal_Int8 > extnv( vlen ) ;
+ css::uno::Sequence< sal_Int8 > extnv( vlen ) ;
for( i = 0; i < vlen ; i ++ )
extnv[i] = *( value + i ) ;
m_xExtnValue = extnv ;
} else {
- m_xExtnValue = Sequence<sal_Int8>();
+ m_xExtnValue = css::uno::Sequence<sal_Int8>();
}
if( id != nullptr && idlen != 0 ) {
- Sequence< sal_Int8 > extnId( idlen ) ;
+ css::uno::Sequence< sal_Int8 > extnId( idlen ) ;
for( i = 0; i < idlen ; i ++ )
extnId[i] = *( id + i ) ;
m_xExtnId = extnId ;
} else {
- m_xExtnId = Sequence<sal_Int8>();
+ m_xExtnId = css::uno::Sequence<sal_Int8>();
}
m_critical = critical ;
diff --git a/xmlsecurity/source/xmlsec/certificateextension_certextn.hxx b/xmlsecurity/source/xmlsec/certificateextension_certextn.hxx
new file mode 100644
index 000000000000..9f4d3842aa33
--- /dev/null
+++ b/xmlsecurity/source/xmlsec/certificateextension_certextn.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF 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 .
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_XMLSEC_CERTIFICATEEXTENSION_CERTEXTN_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_CERTIFICATEEXTENSION_CERTEXTN_HXX
+
+#include <sal/config.h>
+#include <com/sun/star/uno/Sequence.hxx>
+
+struct CertificateExtension_CertExtn
+{
+ bool m_critical;
+ css::uno::Sequence< sal_Int8 > m_xExtnId;
+ css::uno::Sequence< sal_Int8 > m_xExtnValue;
+
+ CertificateExtension_CertExtn();
+ void setCertExtn(unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical);
+};
+
+#endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_CERTIFICATEEXTENSION_CERTEXTN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx
index 0fcbca1a0a83..6c6723f08aad 100644
--- a/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx
+++ b/xmlsecurity/source/xmlsec/certificateextension_xmlsecimpl.hxx
@@ -27,28 +27,36 @@
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/uno/SecurityException.hpp>
#include <com/sun/star/security/XCertificateExtension.hpp>
+#include "certificateextension_certextn.hxx"
class CertificateExtension_XmlSecImpl : public ::cppu::WeakImplHelper<
css::security::XCertificateExtension >
{
private:
- bool m_critical ;
- css::uno::Sequence< sal_Int8 > m_xExtnId ;
- css::uno::Sequence< sal_Int8 > m_xExtnValue ;
+ CertificateExtension_CertExtn m_Extn;
public:
- CertificateExtension_XmlSecImpl() ;
- virtual ~CertificateExtension_XmlSecImpl() ;
-
//Methods from XCertificateExtension
- virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException, std::exception ) override ;
-
- virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException, std::exception ) override ;
-
- virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException, std::exception ) override ;
-
- void setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical ) ;
-} ;
+ virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_critical;
+ }
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_xExtnId;
+ }
+
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_xExtnValue;
+ }
+
+ void setCertExtn(unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical)
+ {
+ m_Extn.setCertExtn(value, vlen, id, idlen, critical);
+ }
+};
#endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_CERTIFICATEEXTENSION_XMLSECIMPL_HXX
diff --git a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
index b41875810bb9..a4ca2a6d28c4 100644
--- a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
@@ -38,29 +38,6 @@ using namespace ::com::sun::star::security ;
using ::com::sun::star::security::XCertificateExtension ;
-
-SanExtensionImpl::SanExtensionImpl() :
-m_critical( false )
-{
-}
-
-SanExtensionImpl::~SanExtensionImpl() {
-}
-
-
-//Methods from XCertificateExtension
-sal_Bool SAL_CALL SanExtensionImpl::isCritical() throw( css::uno::RuntimeException, std::exception ) {
- return m_critical ;
-}
-
-css::uno::Sequence< sal_Int8 > SAL_CALL SanExtensionImpl::getExtensionId() throw( css::uno::RuntimeException, std::exception ) {
- return m_xExtnId ;
-}
-
-css::uno::Sequence< sal_Int8 > SAL_CALL SanExtensionImpl::getExtensionValue() throw( css::uno::RuntimeException, std::exception ) {
- return m_xExtnValue ;
-}
-
namespace {
// Helper functions from nss/lib/certdb/genname.c
int GetNamesLength(CERTGeneralName *names)
@@ -88,8 +65,8 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
SECItem item;
item.type = siDERCertBuffer;
- item.data = reinterpret_cast<unsigned char*>(m_xExtnValue.getArray());
- item.len = m_xExtnValue.getLength();
+ item.data = reinterpret_cast<unsigned char*>(m_Extn.m_xExtnValue.getArray());
+ item.len = m_Extn.m_xExtnValue.getLength();
PRArenaPool *arena;
CERTGeneralName *nameList;
@@ -193,29 +170,4 @@ OString SanExtensionImpl::removeOIDFromString( const OString &oidString)
}
-void SanExtensionImpl::setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical ) {
- unsigned int i ;
- if( value != nullptr && vlen != 0 ) {
- Sequence< sal_Int8 > extnv( vlen ) ;
- for( i = 0; i < vlen ; i ++ )
- extnv[i] = *( value + i ) ;
-
- m_xExtnValue = extnv ;
- } else {
- m_xExtnValue = Sequence<sal_Int8>();
- }
-
- if( id != nullptr && idlen != 0 ) {
- Sequence< sal_Int8 > extnId( idlen ) ;
- for( i = 0; i < idlen ; i ++ )
- extnId[i] = *( id + i ) ;
-
- m_xExtnId = extnId ;
- } else {
- m_xExtnId = Sequence<sal_Int8>();
- }
-
- m_critical = critical ;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx
index 53c6814ef3f2..ca7401884d7f 100644
--- a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx
+++ b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx
@@ -29,30 +29,38 @@
#include <com/sun/star/security/XCertificateExtension.hpp>
#include <com/sun/star/security/XSanExtension.hpp>
#include <com/sun/star/security/CertAltNameEntry.hpp>
+#include "certificateextension_certextn.hxx"
class SanExtensionImpl : public ::cppu::WeakImplHelper<
css::security::XSanExtension >
{
private:
- bool m_critical ;
- css::uno::Sequence< sal_Int8 > m_xExtnId ;
- css::uno::Sequence< sal_Int8 > m_xExtnValue ;
+ CertificateExtension_CertExtn m_Extn;
css::uno::Sequence< css::security::CertAltNameEntry > m_Entries;
static OString removeOIDFromString( const OString &oid);
public:
- SanExtensionImpl() ;
- virtual ~SanExtensionImpl() ;
-
//Methods from XCertificateExtension
- virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException, std::exception ) override ;
+ virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_critical;
+ }
- virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException, std::exception ) override ;
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_xExtnId;
+ }
- virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException, std::exception ) override ;
+ virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException, std::exception ) override
+ {
+ return m_Extn.m_xExtnValue;
+ }
- void setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical ) ;
+ void setCertExtn(unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical)
+ {
+ m_Extn.setCertExtn(value, vlen, id, idlen, critical);
+ }
//Methods from XSanExtension