diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-05 09:54:11 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-05 10:27:45 +0100 |
commit | 88cbfe58c4a36c20bdb2445f43043f0a5a006ee3 (patch) | |
tree | f76b878cbbf944b9f0f08e8390975a6f9201100a /xmlsecurity/source | |
parent | 679cc560bc2cfc6c75b8979cc115c9c54e2b0d40 (diff) |
xmlsecurity: add XMLSignatureHelper::SetDescription()
First step to be able to add a comment while signing a document.
Change-Id: I8f7ab95de5015b723481e94bd72585caf754288f
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 5 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecctl.cxx | 25 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecctl.hxx | 3 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecsign.cxx | 17 |
4 files changed, 49 insertions, 1 deletions
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 496d1b5ea800..2498aff6c66e 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -128,6 +128,11 @@ void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const ::Date& rDate mpXSecController->setDate( nSecurityId, stDateTime ); } +void XMLSignatureHelper::SetDescription(sal_Int32 nSecurityId, const OUString& rDescription) +{ + mpXSecController->setDescription(nSecurityId, rDescription); +} + void XMLSignatureHelper::AddForSigning( sal_Int32 nSecurityId, const OUString& uri, const OUString& objectURL, bool bBinary ) { mpXSecController->signAStream( nSecurityId, uri, objectURL, bBinary ); diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index 3a77b1372051..eed58b55d616 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -37,6 +37,7 @@ namespace cssl = com::sun::star::lang; namespace cssxc = com::sun::star::xml::crypto; namespace cssxs = com::sun::star::xml::sax; namespace cssxw = com::sun::star::xml::wrapper; +using namespace com::sun::star; /* bridge component names */ #define XMLSIGNATURE_COMPONENT "com.sun.star.xml.crypto.XMLSignature" @@ -725,6 +726,7 @@ void XSecController::exportSignature( OUString tag_SignatureProperties(TAG_SIGNATUREPROPERTIES); OUString tag_SignatureProperty(TAG_SIGNATUREPROPERTY); OUString tag_Date(TAG_DATE); + OUString tag_Description(TAG_DESCRIPTION); const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors; SvXMLAttributeList *pAttributeList; @@ -944,6 +946,29 @@ void XSecController::exportSignature( } xDocumentHandler->endElement( tag_SignatureProperty ); } + + // Write signature description. + if (!signatureInfo.ouDescription.isEmpty()) + { + // SignatureProperty element. + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute(ATTR_ID, signatureInfo.ouDescriptionPropertyId); + pAttributeList->AddAttribute(ATTR_TARGET, CHAR_FRAGMENT + signatureInfo.ouSignatureId); + xDocumentHandler->startElement(tag_SignatureProperty, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + + { + // Description element. + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_DC, NS_DC); + + xDocumentHandler->startElement(NSTAG_DC ":" + tag_Description, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + xDocumentHandler->characters(signatureInfo.ouDescription); + xDocumentHandler->endElement(NSTAG_DC ":" + tag_Description); + } + + xDocumentHandler->endElement(tag_SignatureProperty); + } + xDocumentHandler->endElement( tag_SignatureProperties ); } xDocumentHandler->endElement( tag_Object ); diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx index f354bbb03fa1..22b54e984bc3 100644 --- a/xmlsecurity/source/helper/xsecctl.hxx +++ b/xmlsecurity/source/helper/xsecctl.hxx @@ -79,7 +79,7 @@ #define TAG_SIGNATUREPROPERTY "SignatureProperty" #define TAG_TIMESTAMP "timestamp" #define TAG_DATE "date" -//#define TAG_TIME "time" +#define TAG_DESCRIPTION "description" #define ATTR_XMLNS "xmlns" #define ATTR_ALGORITHM "Algorithm" @@ -450,6 +450,7 @@ public: void setDate( sal_Int32 nSecurityId, const ::com::sun::star::util::DateTime& rDateTime ); + void setDescription(sal_Int32 nSecurityId, const OUString& rDescription); bool WriteSignature( diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index 42af9d0460fe..1106e1187a7c 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -258,6 +258,23 @@ void XSecController::setDate( } } +void XSecController::setDescription(sal_Int32 nSecurityId, const OUString& rDescription) +{ + int nIndex = findSignatureInfor(nSecurityId); + + if (nIndex == -1) + { + InternalSignatureInformation aInformation(nSecurityId, nullptr); + aInformation.signatureInfor.ouDescription = rDescription; + m_vInternalSignatureInformations.push_back(aInformation); + } + else + { + SignatureInformation& rInformation = m_vInternalSignatureInformations[nIndex].signatureInfor; + rInformation.ouDescription = rDescription; + } +} + bool XSecController::WriteSignature( const cssu::Reference<cssxs::XDocumentHandler>& xDocumentHandler ) { |