diff options
Diffstat (limited to 'xmlsecurity/source/helper/xsecctl.cxx')
-rw-r--r-- | xmlsecurity/source/helper/xsecctl.cxx | 120 |
1 files changed, 58 insertions, 62 deletions
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index ab108d13c224..cac30006b6a7 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -41,10 +41,6 @@ #include "ooxmlsecexporter.hxx" #include <xmlsignaturehelper2.hxx> -namespace cssu = com::sun::star::uno; -namespace cssl = com::sun::star::lang; -namespace cssxc = com::sun::star::xml::crypto; -namespace cssxs = com::sun::star::xml::sax; using namespace com::sun::star; namespace @@ -53,11 +49,11 @@ OUString getDigestURI(sal_Int32 nID) { switch( nID ) { - case cssxc::DigestID::SHA1: + case css::xml::crypto::DigestID::SHA1: return ALGO_XMLDSIGSHA1; - case cssxc::DigestID::SHA256: + case css::xml::crypto::DigestID::SHA256: return ALGO_XMLDSIGSHA256; - case cssxc::DigestID::SHA512: + case css::xml::crypto::DigestID::SHA512: return ALGO_XMLDSIGSHA512; default: return ALGO_XMLDSIGSHA1; @@ -71,13 +67,13 @@ OUString getSignatureURI(svl::crypto::SignatureMethodAlgorithm eAlgorithm, sal_I { switch (nDigestID) { - case cssxc::DigestID::SHA1: + case css::xml::crypto::DigestID::SHA1: aRet = ALGO_ECDSASHA1; break; - case cssxc::DigestID::SHA256: + case css::xml::crypto::DigestID::SHA256: aRet = ALGO_ECDSASHA256; break; - case cssxc::DigestID::SHA512: + case css::xml::crypto::DigestID::SHA512: aRet = ALGO_ECDSASHA512; break; default: @@ -90,11 +86,11 @@ OUString getSignatureURI(svl::crypto::SignatureMethodAlgorithm eAlgorithm, sal_I switch (nDigestID) { - case cssxc::DigestID::SHA1: + case css::xml::crypto::DigestID::SHA1: return ALGO_RSASHA1; - case cssxc::DigestID::SHA256: + case css::xml::crypto::DigestID::SHA256: return ALGO_RSASHA256; - case cssxc::DigestID::SHA512: + case css::xml::crypto::DigestID::SHA512: return ALGO_RSASHA512; default: return ALGO_RSASHA1; @@ -102,7 +98,7 @@ OUString getSignatureURI(svl::crypto::SignatureMethodAlgorithm eAlgorithm, sal_I } } -XSecController::XSecController( const cssu::Reference<cssu::XComponentContext>& rxCtx ) +XSecController::XSecController( const css::uno::Reference<css::uno::XComponentContext>& rxCtx ) : mxCtx(rxCtx) , m_nNextSecurityId(1) , m_bIsPreviousNodeInitializable(false) @@ -177,15 +173,15 @@ void XSecController::createXSecComponent( ) m_xXMLDocumentWrapper = nullptr; m_xSAXEventKeeper = nullptr; - cssu::Reference< cssl::XMultiComponentFactory > xMCF( mxCtx->getServiceManager() ); + css::uno::Reference< css::lang::XMultiComponentFactory > xMCF( mxCtx->getServiceManager() ); #if HAVE_FEATURE_GPGME - uno::Reference< lang::XServiceInfo > xServiceInfo( m_xSecurityContext, cssu::UNO_QUERY ); + uno::Reference< lang::XServiceInfo > xServiceInfo( m_xSecurityContext, css::uno::UNO_QUERY ); if (xServiceInfo->getImplementationName() == "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl") m_xXMLSignature.set(new XMLSignature_GpgImpl()); else // xmlsec or mscrypt #endif - m_xXMLSignature.set(xMCF->createInstanceWithContext("com.sun.star.xml.crypto.XMLSignature", mxCtx), cssu::UNO_QUERY); + m_xXMLSignature.set(xMCF->createInstanceWithContext("com.sun.star.xml.crypto.XMLSignature", mxCtx), css::uno::UNO_QUERY); bool bSuccess = m_xXMLSignature.is(); if ( bSuccess ) @@ -205,11 +201,11 @@ void XSecController::createXSecComponent( ) * SAXEventKeeper created successfully. */ { - cssu::Sequence <cssu::Any> arg(1); + css::uno::Sequence <css::uno::Any> arg(1); arg[0] <<= uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper.get()); m_xSAXEventKeeper->initialize(arg); - cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener > + css::uno::Reference< css::xml::crypto::sax::XSAXEventKeeperStatusChangeListener > xStatusChangeListener = this; m_xSAXEventKeeper->addSAXEventKeeperStatusChangeListener( xStatusChangeListener ); @@ -272,7 +268,7 @@ bool XSecController::chainOn() */ m_xSAXEventKeeper->setNextHandler( nullptr ); - cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), cssu::UNO_QUERY); + css::uno::Reference< css::xml::sax::XDocumentHandler > xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), css::uno::UNO_QUERY); /* * connects the previous document handler on the SAX chain @@ -281,17 +277,17 @@ bool XSecController::chainOn() { if ( m_bIsPreviousNodeInitializable ) { - cssu::Reference< cssl::XInitialization > xInitialization - (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + css::uno::Reference< css::lang::XInitialization > xInitialization + (m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY); - cssu::Sequence<cssu::Any> aArgs( 1 ); + css::uno::Sequence<css::uno::Any> aArgs( 1 ); aArgs[0] <<= xSEKHandler; xInitialization->initialize(aArgs); } else { - cssu::Reference< cssxs::XParser > xParser - (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + css::uno::Reference< css::xml::sax::XParser > xParser + (m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY); xParser->setDocumentHandler( xSEKHandler ); } } @@ -327,16 +323,16 @@ void XSecController::chainOff() { if ( m_bIsPreviousNodeInitializable ) { - cssu::Reference< cssl::XInitialization > xInitialization - (m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + css::uno::Reference< css::lang::XInitialization > xInitialization + (m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY); - cssu::Sequence<cssu::Any> aArgs( 1 ); + css::uno::Sequence<css::uno::Any> aArgs( 1 ); aArgs[0] <<= uno::Reference<xml::sax::XDocumentHandler>(); xInitialization->initialize(aArgs); } else { - cssu::Reference< cssxs::XParser > xParser(m_xPreviousNodeOnSAXChain, cssu::UNO_QUERY); + css::uno::Reference< css::xml::sax::XParser > xParser(m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY); xParser->setDocumentHandler(uno::Reference<xml::sax::XDocumentHandler>()); } } @@ -393,7 +389,7 @@ void XSecController::initializeSAXChain() chainOff(); } -cssu::Reference< css::io::XInputStream > +css::uno::Reference< css::io::XInputStream > XSecController::getObjectInputStream( const OUString& objectURL ) /****** XSecController/getObjectInputStream ************************************ * @@ -410,7 +406,7 @@ cssu::Reference< css::io::XInputStream > * xInputStream - the XInputStream interface ******************************************************************************/ { - cssu::Reference< css::io::XInputStream > xObjectInputStream; + css::uno::Reference< css::io::XInputStream > xObjectInputStream; SAL_WARN_IF( !m_xUriBinding.is(), "xmlsecurity.helper", "Need XUriBinding!" ); @@ -430,7 +426,7 @@ sal_Int32 XSecController::getNewSecurityId( ) return nId; } -void XSecController::startMission(const rtl::Reference<UriBindingHelper>& xUriBinding, const cssu::Reference< cssxc::XXMLSecurityContext >& xSecurityContext ) +void XSecController::startMission(const rtl::Reference<UriBindingHelper>& xUriBinding, const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& xSecurityContext ) /****** XSecController/startMission ******************************************* * * NAME @@ -456,7 +452,7 @@ void XSecController::startMission(const rtl::Reference<UriBindingHelper>& xUriBi m_bVerifyCurrentSignature = false; } -void XSecController::setSAXChainConnector(const cssu::Reference< cssl::XInitialization >& xInitialization) +void XSecController::setSAXChainConnector(const css::uno::Reference< css::lang::XInitialization >& xInitialization) /****** XSecController/setSAXChainConnector *********************************** * * NAME @@ -507,8 +503,8 @@ void XSecController::endMission() * ResolvedListener only exist when the security components are created. */ { - cssu::Reference< cssxc::sax::XMissionTaker > xMissionTaker - ( m_vInternalSignatureInformations[i].xReferenceResolvedListener, cssu::UNO_QUERY ); + css::uno::Reference< css::xml::crypto::sax::XMissionTaker > xMissionTaker + ( m_vInternalSignatureInformations[i].xReferenceResolvedListener, css::uno::UNO_QUERY ); /* * asks the SignatureCreator/SignatureVerifier to release @@ -567,7 +563,7 @@ void writeUnsignedProperties( } void XSecController::exportSignature( - const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler, + const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& signatureInfo, bool bXAdESCompliantIfODF ) /****** XSecController/exportSignature **************************************** @@ -601,19 +597,19 @@ void XSecController::exportSignature( signatureInfo.ouSignatureId); } - xDocumentHandler->startElement( "Signature", cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + xDocumentHandler->startElement( "Signature", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); { /* Write SignedInfo element */ xDocumentHandler->startElement( "SignedInfo", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { /* Write CanonicalizationMethod element */ pAttributeList = new SvXMLAttributeList(); pAttributeList->AddAttribute( "Algorithm", ALGO_C14N); - xDocumentHandler->startElement( "CanonicalizationMethod", cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->startElement( "CanonicalizationMethod", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) ); xDocumentHandler->endElement( "CanonicalizationMethod" ); /* Write SignatureMethod element */ @@ -627,7 +623,7 @@ void XSecController::exportSignature( pAttributeList->AddAttribute( "Algorithm", getSignatureURI(signatureInfo.eAlgorithmID, vReferenceInfors[0].nDigestID)); - xDocumentHandler->startElement( "SignatureMethod", cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->startElement( "SignatureMethod", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) ); xDocumentHandler->endElement( "SignatureMethod" ); /* Write Reference element */ @@ -666,7 +662,7 @@ void XSecController::exportSignature( } } - xDocumentHandler->startElement( "Reference", cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + xDocumentHandler->startElement( "Reference", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) ); { /* Write Transforms element */ if (refInfor.nType == SignatureReferenceType::XMLSTREAM) @@ -676,7 +672,7 @@ void XSecController::exportSignature( { xDocumentHandler->startElement( "Transforms", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { pAttributeList = new SvXMLAttributeList(); pAttributeList->AddAttribute( @@ -684,7 +680,7 @@ void XSecController::exportSignature( ALGO_C14N); xDocumentHandler->startElement( "Transform", - cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) ); xDocumentHandler->endElement( "Transform" ); } xDocumentHandler->endElement( "Transforms" ); @@ -697,13 +693,13 @@ void XSecController::exportSignature( getDigestURI(refInfor.nDigestID)); xDocumentHandler->startElement( "DigestMethod", - cssu::Reference< cssxs::XAttributeList > (pAttributeList) ); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) ); xDocumentHandler->endElement( "DigestMethod" ); /* Write DigestValue element */ xDocumentHandler->startElement( "DigestValue", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( refInfor.ouDigestValue ); xDocumentHandler->endElement( "DigestValue" ); } @@ -715,14 +711,14 @@ void XSecController::exportSignature( /* Write SignatureValue element */ xDocumentHandler->startElement( "SignatureValue", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouSignatureValue ); xDocumentHandler->endElement( "SignatureValue" ); /* Write KeyInfo element */ xDocumentHandler->startElement( "KeyInfo", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { // GPG or X509 key? if (!signatureInfo.ouGpgCertificate.isEmpty()) @@ -732,12 +728,12 @@ void XSecController::exportSignature( /* Write PGPData element */ xDocumentHandler->startElement( "PGPData", - cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); { /* Write keyid element */ xDocumentHandler->startElement( "PGPKeyID", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouCertDigest ); xDocumentHandler->endElement( "PGPKeyID" ); @@ -746,7 +742,7 @@ void XSecController::exportSignature( { xDocumentHandler->startElement( "PGPKeyPacket", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouGpgCertificate ); xDocumentHandler->endElement( "PGPKeyPacket" ); } @@ -754,7 +750,7 @@ void XSecController::exportSignature( /* Write PGPOwner element */ xDocumentHandler->startElement( "loext:PGPOwner", - cssu::Reference< cssxs::XAttributeList >(new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList >(new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouGpgOwner ); xDocumentHandler->endElement( "loext:PGPOwner" ); } @@ -765,24 +761,24 @@ void XSecController::exportSignature( /* Write X509Data element */ xDocumentHandler->startElement( "X509Data", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { /* Write X509IssuerSerial element */ xDocumentHandler->startElement( "X509IssuerSerial", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { /* Write X509IssuerName element */ xDocumentHandler->startElement( "X509IssuerName", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouX509IssuerName ); xDocumentHandler->endElement( "X509IssuerName" ); /* Write X509SerialNumber element */ xDocumentHandler->startElement( "X509SerialNumber", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouX509SerialNumber ); xDocumentHandler->endElement( "X509SerialNumber" ); } @@ -793,7 +789,7 @@ void XSecController::exportSignature( { xDocumentHandler->startElement( "X509Certificate", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); xDocumentHandler->characters( signatureInfo.ouX509Certificate ); xDocumentHandler->endElement( "X509Certificate" ); } @@ -808,12 +804,12 @@ void XSecController::exportSignature( /* Write Object element */ xDocumentHandler->startElement( "Object", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { /* Write SignatureProperties element */ xDocumentHandler->startElement( "SignatureProperties", - cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList())); + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); { /* Write SignatureProperty element */ pAttributeList = new SvXMLAttributeList(); @@ -825,7 +821,7 @@ void XSecController::exportSignature( "#" + signatureInfo.ouSignatureId); xDocumentHandler->startElement( "SignatureProperty", - cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); { /* Write timestamp element */ @@ -836,7 +832,7 @@ void XSecController::exportSignature( xDocumentHandler->startElement( "dc:date", - cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); OUStringBuffer buffer; //If the xml signature was already contained in the document, @@ -894,13 +890,13 @@ void XSecController::exportSignature( pAttributeList->AddAttribute("xmlns:xd", NS_XD); xDocumentHandler->startElement( "Object", - cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); { pAttributeList = new SvXMLAttributeList(); pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId); xDocumentHandler->startElement( "xd:QualifyingProperties", - cssu::Reference< cssxs::XAttributeList > (pAttributeList)); + css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList)); DocumentSignatureHelper::writeSignedProperties(xDocumentHandler, signatureInfo, sDate, true); writeUnsignedProperties(xDocumentHandler, signatureInfo); xDocumentHandler->endElement( "xd:QualifyingProperties" ); |