summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/helper
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-07-10 10:02:10 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-10 15:41:44 +0200
commit820bd4b3b64a5746599c48c729037a959ff61c84 (patch)
tree720e47094e0981b6fbcacdea5b963c92d3210e52 /xmlsecurity/source/helper
parentc86be45d343635f2e137b8ea710d87e1a612101d (diff)
tdf#108977 Show signature info also for keys we don't have locally
gpg4libre Change-Id: I89593224590007e61bce95c14922c08551282067 Reviewed-on: https://gerrit.libreoffice.org/39742 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'xmlsecurity/source/helper')
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx2
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx6
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx7
-rw-r--r--xmlsecurity/source/helper/xsecparser.cxx16
-rw-r--r--xmlsecurity/source/helper/xsecparser.hxx2
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx5
-rw-r--r--xmlsecurity/source/helper/xsecverify.cxx11
7 files changed, 45 insertions, 4 deletions
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 01bcbc0dab9f..12e76685c8d2 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -291,7 +291,7 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
else
SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one");
- maSignatureHelper.SetGpgCertificate(nSecurityId, aKeyId, aStrBuffer.makeStringAndClear());
+ maSignatureHelper.SetGpgCertificate(nSecurityId, aKeyId, aStrBuffer.makeStringAndClear(), xCert->getIssuerName());
}
else
{
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index b6078d373916..c7841a5d5614 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -125,12 +125,14 @@ void XMLSignatureHelper::AddEncapsulatedX509Certificate(const OUString& ouEncaps
void XMLSignatureHelper::SetGpgCertificate(sal_Int32 nSecurityId,
const OUString& ouGpgCertDigest,
- const OUString& ouGpgCert)
+ const OUString& ouGpgCert,
+ const OUString& ouGpgOwner)
{
mpXSecController->setGpgCertificate(
nSecurityId,
ouGpgCertDigest,
- ouGpgCert);
+ ouGpgCert,
+ ouGpgOwner);
}
void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const ::Date& rDate, const tools::Time& rTime )
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index 795745fe851b..0d92cb0f0b54 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -747,6 +747,13 @@ void XSecController::exportSignature(
xDocumentHandler->characters( signatureInfo.ouGpgCertificate );
xDocumentHandler->endElement( "PGPKeyPacket" );
}
+
+ /* Write PGPOwner element */
+ xDocumentHandler->startElement(
+ "PGPOwner",
+ cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
+ xDocumentHandler->characters( signatureInfo.ouGpgOwner );
+ xDocumentHandler->endElement( "PGPOwner" );
}
xDocumentHandler->endElement( "PGPData" );
}
diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index 360d39e326f4..00054b4f3ef4 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -36,6 +36,7 @@ XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper,
, m_bInX509Certificate(false)
, m_bInGpgCertificate(false)
, m_bInGpgKeyID(false)
+ , m_bInGpgOwner(false)
, m_bInCertDigest(false)
, m_bInEncapsulatedX509Certificate(false)
, m_bInSigningTime(false)
@@ -72,6 +73,7 @@ void SAL_CALL XSecParser::startDocument( )
m_bInX509Certificate = false;
m_bInGpgCertificate = false;
m_bInGpgKeyID = false;
+ m_bInGpgOwner = false;
m_bInSignatureValue = false;
m_bInDigestValue = false;
m_bInDate = false;
@@ -192,6 +194,11 @@ void SAL_CALL XSecParser::startElement(
m_ouGpgCertificate.clear();
m_bInGpgCertificate = true;
}
+ else if (aName == "PGPOwner")
+ {
+ m_ouGpgOwner.clear();
+ m_bInGpgOwner = true;
+ }
else if (aName == "SignatureValue")
{
m_ouSignatureValue.clear();
@@ -315,6 +322,11 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
m_pXSecController->setGpgCertificate( m_ouGpgCertificate );
m_bInGpgCertificate = false;
}
+ else if (aName == "PGPOwner")
+ {
+ m_pXSecController->setGpgOwner( m_ouGpgOwner );
+ m_bInGpgOwner = false;
+ }
else if (aName == "xd:CertDigest")
{
m_pXSecController->setCertDigest( m_ouCertDigest );
@@ -386,6 +398,10 @@ void SAL_CALL XSecParser::characters( const OUString& aChars )
{
m_ouGpgKeyID += aChars;
}
+ else if (m_bInGpgOwner)
+ {
+ m_ouGpgOwner += aChars;
+ }
else if (m_bInSignatureValue)
{
m_ouSignatureValue += aChars;
diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx
index acf9909a2580..f2f59185d54d 100644
--- a/xmlsecurity/source/helper/xsecparser.hxx
+++ b/xmlsecurity/source/helper/xsecparser.hxx
@@ -59,6 +59,7 @@ private:
OUString m_ouX509Certificate;
OUString m_ouGpgCertificate;
OUString m_ouGpgKeyID;
+ OUString m_ouGpgOwner;
OUString m_ouCertDigest;
OUString m_ouEncapsulatedX509Certificate;
OUString m_ouDigestValue;
@@ -75,6 +76,7 @@ private:
bool m_bInX509Certificate;
bool m_bInGpgCertificate;
bool m_bInGpgKeyID;
+ bool m_bInGpgOwner;
bool m_bInCertDigest;
bool m_bInEncapsulatedX509Certificate;
bool m_bInSigningTime;
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 452613b4d10b..278eba79f8af 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -242,7 +242,8 @@ void XSecController::setX509Certificate(
void XSecController::setGpgCertificate(
sal_Int32 nSecurityId,
const OUString& ouCertDigest,
- const OUString& ouCert)
+ const OUString& ouCert,
+ const OUString& ouOwner)
{
int index = findSignatureInfor( nSecurityId );
@@ -250,6 +251,7 @@ void XSecController::setGpgCertificate(
{
InternalSignatureInformation isi(nSecurityId, nullptr);
isi.signatureInfor.ouGpgCertificate = ouCert;
+ isi.signatureInfor.ouGpgOwner = ouOwner;
isi.signatureInfor.ouCertDigest = ouCertDigest;
m_vInternalSignatureInformations.push_back( isi );
}
@@ -258,6 +260,7 @@ void XSecController::setGpgCertificate(
SignatureInformation &si
= m_vInternalSignatureInformations[index].signatureInfor;
si.ouGpgCertificate = ouCert;
+ si.ouGpgOwner = ouOwner;
si.ouCertDigest = ouCertDigest;
}
}
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index cd27355acc67..c9602ecfd2fe 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -294,6 +294,17 @@ void XSecController::setGpgCertificate( OUString& ouGpgCert )
isi.signatureInfor.ouGpgCertificate = ouGpgCert;
}
+void XSecController::setGpgOwner( OUString& ouGpgOwner )
+{
+ if (m_vInternalSignatureInformations.empty())
+ {
+ SAL_INFO("xmlsecurity.helper","XSecController::setGpgOwner: no signature");
+ return;
+ }
+ InternalSignatureInformation &isi = m_vInternalSignatureInformations.back();
+ isi.signatureInfor.ouGpgOwner = ouGpgOwner;
+}
+
void XSecController::setDate( OUString& ouDate )
{
if (m_vInternalSignatureInformations.empty())