diff options
Diffstat (limited to 'xmlsecurity/source/xmlsec')
8 files changed, 76 insertions, 26 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index 8ae78b105403..35b3835a2afe 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -594,6 +594,11 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getMD5Thumb return getThumbprint(m_pCertContext, CERT_MD5_HASH_PROP_ID); } +CertificateKind SAL_CALL X509Certificate_MSCryptImpl::getCertificateKind() +{ + return CertificateKind_X509; +} + sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) { sal_Int32 usage = diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx index f7ba8a21a3fc..ce63a8acc170 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/SecurityException.hpp> +#include <com/sun/star/security/CertificateKind.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <certificate.hxx> @@ -67,6 +68,8 @@ class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper< virtual OUString SAL_CALL getSignatureAlgorithm() override; virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSHA1Thumbprint() override; virtual css::uno::Sequence< sal_Int8 > SAL_CALL getMD5Thumbprint() override; + virtual css::security::CertificateKind SAL_CALL getCertificateKind() override; + virtual sal_Int32 SAL_CALL getCertificateUsage( ) override; diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx index cc93f1be46b7..079be582e02b 100644 --- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx @@ -455,6 +455,11 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getMD5Thumbprin return getThumbprint(m_pCert, SEC_OID_MD5); } +CertificateKind SAL_CALL X509Certificate_NssImpl::getCertificateKind() +{ + return CertificateKind_X509; +} + sal_Int32 SAL_CALL X509Certificate_NssImpl::getCertificateUsage( ) { SECStatus rv; diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx index 08e9cf1185e7..58759673935b 100644 --- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx +++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/SecurityException.hpp> +#include <com/sun/star/security/CertificateKind.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <certificate.hxx> @@ -72,6 +73,7 @@ class X509Certificate_NssImpl : public ::cppu::WeakImplHelper< virtual css::uno::Sequence< sal_Int8 > SAL_CALL getSHA1Thumbprint() override ; virtual css::uno::Sequence< sal_Int8 > SAL_CALL getMD5Thumbprint() override ; + virtual css::security::CertificateKind SAL_CALL getCertificateKind() override; virtual sal_Int32 SAL_CALL getCertificateUsage( ) override ; diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx index 6b7a78b1e6a1..371a27f3d090 100644 --- a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx @@ -22,9 +22,6 @@ #include "securityenvironment_nssimpl.hxx" #include "xmlsecuritycontext_nssimpl.hxx" -#include "xmlsec/xmlstreamio.hxx" - -#include "xmlsec-wrapper.h" using namespace ::com::sun::star::uno ; using namespace ::com::sun::star::lang ; @@ -37,30 +34,10 @@ using ::com::sun::star::xml::crypto::XXMLSecurityContext ; XMLSecurityContext_NssImpl::XMLSecurityContext_NssImpl() : m_nDefaultEnvIndex(-1) { - //Init xmlsec library - if( xmlSecInit() < 0 ) { - throw RuntimeException() ; - } - - //Init xmlsec crypto engine library - if( xmlSecCryptoInit() < 0 ) { - xmlSecShutdown() ; - throw RuntimeException() ; - } - - //Enable external stream handlers - if( xmlEnableStreamInputCallbacks() < 0 ) { - xmlSecCryptoShutdown() ; - xmlSecShutdown() ; - throw RuntimeException() ; - } } XMLSecurityContext_NssImpl::~XMLSecurityContext_NssImpl() { - xmlDisableStreamInputCallbacks() ; - xmlSecCryptoShutdown() ; - xmlSecShutdown() ; } sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::addSecurityEnvironment( diff --git a/xmlsecurity/source/xmlsec/xmlsec_init.cxx b/xmlsecurity/source/xmlsec/xmlsec_init.cxx new file mode 100644 index 000000000000..9b2fe90f87c2 --- /dev/null +++ b/xmlsecurity/source/xmlsec/xmlsec_init.cxx @@ -0,0 +1,47 @@ +/* -*- 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/. + */ + +#include "xmlsec/xmlsec_init.hxx" + +#include <com/sun/star/uno/RuntimeException.hpp> + +#include "xmlsec/xmlstreamio.hxx" +#include "xmlsec-wrapper.h" + +using namespace css::uno; + +XSECXMLSEC_DLLPUBLIC void initXmlSec() +{ + //Init xmlsec library + if( xmlSecInit() < 0 ) { + throw RuntimeException() ; + } + + //Init xmlsec crypto engine library + if( xmlSecCryptoInit() < 0 ) { + xmlSecShutdown() ; + throw RuntimeException() ; + } + + //Enable external stream handlers + if( xmlEnableStreamInputCallbacks() < 0 ) { + xmlSecCryptoShutdown() ; + xmlSecShutdown() ; + throw RuntimeException() ; + } +} + +XSECXMLSEC_DLLPUBLIC void deInitXmlSec() +{ + xmlDisableStreamInputCallbacks(); + xmlSecCryptoShutdown(); + xmlSecShutdown(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/xmlstreamio.cxx b/xmlsecurity/source/xmlsec/xmlstreamio.cxx index 6faf711c181b..32d86269cd7e 100644 --- a/xmlsecurity/source/xmlsec/xmlstreamio.cxx +++ b/xmlsecurity/source/xmlsec/xmlstreamio.cxx @@ -145,7 +145,7 @@ int xmlStreamClose( void * context ) return 0 ; } -int xmlEnableStreamInputCallbacks() +XSECXMLSEC_DLLPUBLIC int xmlEnableStreamInputCallbacks() { if( !( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) ) { @@ -210,7 +210,7 @@ XSECXMLSEC_DLLPUBLIC int xmlUnregisterStreamInputCallbacks() return 0 ; } -void xmlDisableStreamInputCallbacks() { +XSECXMLSEC_DLLPUBLIC void xmlDisableStreamInputCallbacks() { xmlUnregisterStreamInputCallbacks() ; enableXmlStreamIO &= ~XMLSTREAMIO_INITIALIZED ; } diff --git a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx index 99738064c09f..b480b90a9235 100644 --- a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx +++ b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx @@ -27,6 +27,10 @@ #include "xmlsec/xmldocumentwrapper_xmlsecimpl.hxx" #include "xsec_xmlsec.hxx" +#if !defined(MACOSX) && !defined(WNT) +# include "gpg/xmlsignature_gpgimpl.hxx" +#endif + using namespace ::cppu; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -40,7 +44,14 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL xsec_xmlsec_component_getFactory( const sal_ Reference< XInterface > xFactory ; if( pImplName != nullptr ) { - if( XMLElementWrapper_XmlSecImpl_getImplementationName().equalsAscii( pImplName ) ) +#if !defined(MACOSX) && !defined(WNT) + if( XMLSignature_GpgImpl::impl_getImplementationName().equalsAscii( pImplName ) ) + { + xFactory = XMLSignature_GpgImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + } + else +#endif + if( XMLElementWrapper_XmlSecImpl_getImplementationName().equalsAscii( pImplName ) ) { xFactory = cppu::createSingleComponentFactory( XMLElementWrapper_XmlSecImpl_createInstance, |