summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/helper/xsecsign.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity/source/helper/xsecsign.cxx')
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx98
1 files changed, 49 insertions, 49 deletions
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 774a07cb28f2..2285373c50f6 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -55,14 +55,14 @@ rtl::OUString XSecController::createId()
{
cssu::Sequence< sal_Int8 > aSeq( 16 );
rtl_createUuid ((sal_uInt8 *)aSeq.getArray(), 0, sal_True);
-
+
char str[68]="ID_";
int length = 3;
for (int i=0; i<16; ++i)
{
length += sprintf(str+length, "%04x", (unsigned char)aSeq[i]);
}
-
+
return rtl::OUString::createFromAscii(str);
}
@@ -71,11 +71,11 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
{
sal_Int32 nSecurityId = internalSignatureInfor.signatureInfor.nSecurityId;
SignatureReferenceInformations& vReferenceInfors = internalSignatureInfor.signatureInfor.vSignatureReferenceInfors;
-
+
sal_Int32 nIdOfSignatureElementCollector;
cssu::Reference< cssxc::sax::XReferenceResolvedListener > xReferenceResolvedListener;
- nIdOfSignatureElementCollector =
+ nIdOfSignatureElementCollector =
m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_AFTERMODIFY, sal_True );
m_xSAXEventKeeper->setSecurityId(nIdOfSignatureElementCollector, nSecurityId);
@@ -88,14 +88,14 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
xMCF->createInstanceWithContext(
rtl::OUString::createFromAscii(SIGNATURECREATOR_COMPONENT), mxCtx),
cssu::UNO_QUERY);
-
+
cssu::Reference<cssl::XInitialization> xInitialization(xReferenceResolvedListener, cssu::UNO_QUERY);
cssu::Sequence<cssu::Any> args(5);
args[0] = cssu::makeAny(rtl::OUString::valueOf(nSecurityId));
args[1] = cssu::makeAny(m_xSAXEventKeeper);
args[2] = cssu::makeAny(rtl::OUString::valueOf(nIdOfSignatureElementCollector));
-
+
//i39448 : for nss, the internal module is used for signing, which needs to be improved later
sal_Int32 nEnvIndex = internalSignatureInfor.signatureInfor.nSecurityEnvironmentIndex;
if( nEnvIndex < 0 || nEnvIndex >= m_xSecurityContext->getSecurityEnvironmentNumber())
@@ -106,41 +106,41 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
{
args[3] = cssu::makeAny(m_xSecurityContext->getSecurityEnvironmentByIndex(nEnvIndex));
}
-
+
args[4] = cssu::makeAny(m_xXMLSignature);
xInitialization->initialize(args);
-
+
sal_Int32 nBlockerId = m_xSAXEventKeeper->addBlocker();
m_xSAXEventKeeper->setSecurityId(nBlockerId, nSecurityId);
-
+
cssu::Reference<cssxc::sax::XBlockerMonitor> xBlockerMonitor(xReferenceResolvedListener, cssu::UNO_QUERY);
xBlockerMonitor->setBlockerId(nBlockerId);
cssu::Reference< cssxc::sax::XSignatureCreationResultBroadcaster >
xSignatureCreationResultBroadcaster(xReferenceResolvedListener, cssu::UNO_QUERY);
-
+
xSignatureCreationResultBroadcaster->addSignatureCreationResultListener( this );
-
- cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster>
- xReferenceResolvedBroadcaster
+
+ cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster>
+ xReferenceResolvedBroadcaster
(m_xSAXEventKeeper,
cssu::UNO_QUERY);
-
+
xReferenceResolvedBroadcaster->addReferenceResolvedListener(
nIdOfSignatureElementCollector,
xReferenceResolvedListener);
-
+
cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector
(xReferenceResolvedListener, cssu::UNO_QUERY);
-
+
int i;
int size = vReferenceInfors.size();
sal_Int32 nReferenceCount = 0;
-
+
for(i=0; i<size; ++i)
{
sal_Int32 keeperId = internalSignatureInfor.vKeeperIds[i];
-
+
if ( keeperId != -1)
{
m_xSAXEventKeeper->setSecurityId(keeperId, nSecurityId);
@@ -149,19 +149,19 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
nReferenceCount++;
}
}
-
+
xReferenceCollector->setReferenceCount( nReferenceCount );
-
+
/*
* adds all URI binding
*/
cssu::Reference<cssxc::XUriBinding> xUriBinding
(xReferenceResolvedListener, cssu::UNO_QUERY);
-
+
for(i=0; i<size; ++i)
{
const SignatureReferenceInformation& refInfor = vReferenceInfors[i];
-
+
cssu::Reference< com::sun::star::io::XInputStream > xInputStream
= getObjectInputStream( refInfor.ouURI );
@@ -170,15 +170,15 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
xUriBinding->setUriBinding(refInfor.ouURI,xInputStream);
}
}
-
+
cssu::Reference<cssxc::sax::XKeyCollector> keyCollector (xReferenceResolvedListener, cssu::UNO_QUERY);
keyCollector->setKeyId(0);
-
+
internalSignatureInfor.signatureInfor.ouSignatureId = createId();
internalSignatureInfor.signatureInfor.ouPropertyId = createId();
internalSignatureInfor.addReference(TYPE_SAMEDOCUMENT_REFERENCE, internalSignatureInfor.signatureInfor.ouPropertyId, -1 );
size++;
-
+
/*
* replace both digestValues and signatueValue to " "
*/
@@ -189,7 +189,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
}
internalSignatureInfor.signatureInfor.ouSignatureValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CHAR_BLANK));
-
+
return xReferenceResolvedListener;
}
@@ -197,9 +197,9 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
void XSecController::collectToSign( sal_Int32 securityId, const rtl::OUString& referenceId )
{
/* DBG_ASSERT( m_xSAXEventKeeper.is(), "the SAXEventKeeper is NULL" ); */
-
+
chainOn(true);
-
+
if ( m_nStatusOfSecurityComponents == INITIALIZED )
/*
* if all security components are ready, add a signature.
@@ -207,9 +207,9 @@ void XSecController::collectToSign( sal_Int32 securityId, const rtl::OUString& r
{
sal_Int32 nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector(
cssxc::sax::ElementMarkPriority_AFTERMODIFY, sal_False);
-
+
int index = findSignatureInfor( securityId );
-
+
if ( index == -1 )
{
InternalSignatureInformation isi(securityId, NULL);
@@ -226,9 +226,9 @@ void XSecController::collectToSign( sal_Int32 securityId, const rtl::OUString& r
void XSecController::signAStream( sal_Int32 securityId, const rtl::OUString& uri, const rtl::OUString& /*objectURL*/, sal_Bool isBinary)
{
sal_Int32 type = ((isBinary==sal_True)?TYPE_BINARYSTREAM_REFERENCE:TYPE_XMLSTREAM_REFERENCE);
-
+
int index = findSignatureInfor( securityId );
-
+
if (index == -1)
{
InternalSignatureInformation isi(securityId, NULL);
@@ -252,7 +252,7 @@ void XSecController::setX509Certificate(
void XSecController::setX509Certificate(
sal_Int32 nSecurityId,
- const sal_Int32 nSecurityEnvironmentIndex,
+ const sal_Int32 nSecurityEnvironmentIndex,
const rtl::OUString& ouX509IssuerName,
const rtl::OUString& ouX509SerialNumber,
const rtl::OUString& ouX509Cert)
@@ -303,14 +303,14 @@ bool XSecController::WriteSignature(
const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler )
{
bool rc = false;
-
+
DBG_ASSERT( xDocumentHandler.is(), "I really need a document handler!" );
-
+
/*
- * chain the SAXEventKeeper to the SAX chain
+ * chain the SAXEventKeeper to the SAX chain
*/
chainOn(true);
-
+
if ( m_nStatusOfSecurityComponents == INITIALIZED )
/*
* if all security components are ready, add the signature
@@ -319,33 +319,33 @@ bool XSecController::WriteSignature(
{
m_bIsSAXEventKeeperSticky = true;
m_xSAXEventKeeper->setNextHandler(xDocumentHandler);
-
+
try
{
/*
- * export the signature template
+ * export the signature template
*/
cssu::Reference<cssxs::XDocumentHandler> xSEKHandler( m_xSAXEventKeeper,cssu::UNO_QUERY);
-
+
int i;
int sigNum = m_vInternalSignatureInformations.size();
-
+
for (i=0; i<sigNum; ++i)
{
InternalSignatureInformation &isi = m_vInternalSignatureInformations[i];
-
+
/*
* prepare the signature creator
*/
- isi.xReferenceResolvedListener
+ isi.xReferenceResolvedListener
= prepareSignatureToWrite( isi );
-
+
exportSignature( xSEKHandler, isi.signatureInfor );
}
-
+
m_bIsSAXEventKeeperSticky = false;
chainOff();
-
+
rc = true;
}
catch( cssxs::SAXException& )
@@ -360,7 +360,7 @@ bool XSecController::WriteSignature(
{
m_pErrorMessage = ERROR_EXCEPTIONDURINGCREATION;
}
-
+
m_xSAXEventKeeper->setNextHandler( NULL );
m_bIsSAXEventKeeperSticky = false;
}
@@ -368,7 +368,7 @@ bool XSecController::WriteSignature(
{
m_pErrorMessage = ERROR_CANNOTCREATEXMLSECURITYCOMPONENT;
}
-
+
return rc;
}