Kaydet (Commit) 820bd4b3 authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt Kaydeden (comit) Thorsten Behrens

tdf#108977 Show signature info also for keys we don't have locally

gpg4libre

Change-Id: I89593224590007e61bce95c14922c08551282067
Reviewed-on: https://gerrit.libreoffice.org/39742Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst c86be45d
...@@ -77,6 +77,7 @@ struct SignatureInformation ...@@ -77,6 +77,7 @@ struct SignatureInformation
OUString ouGpgKeyID; OUString ouGpgKeyID;
OUString ouGpgCertificate; OUString ouGpgCertificate;
OUString ouGpgOwner;
OUString ouSignatureValue; OUString ouSignatureValue;
css::util::DateTime stDateTime; css::util::DateTime stDateTime;
......
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
void AddEncapsulatedX509Certificate(const OUString& ouEncapsulatedX509Certificate); void AddEncapsulatedX509Certificate(const OUString& ouEncapsulatedX509Certificate);
void SetGpgCertificate(sal_Int32 nSecurityId, const OUString& ouGpgCertDigest, void SetGpgCertificate(sal_Int32 nSecurityId, const OUString& ouGpgCertDigest,
const OUString& ouGpgCert); const OUString& ouGpgCert, const OUString& ouGpgOwner);
void SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const tools::Time& rTime ); void SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const tools::Time& rTime );
void SetDescription(sal_Int32 nSecurityId, const OUString& rDescription); void SetDescription(sal_Int32 nSecurityId, const OUString& rDescription);
......
...@@ -309,6 +309,7 @@ private: ...@@ -309,6 +309,7 @@ private:
void setDigestValue( sal_Int32 nDigestID, OUString& ouDigestValue ); void setDigestValue( sal_Int32 nDigestID, OUString& ouDigestValue );
void setGpgKeyID( OUString& ouKeyID ); void setGpgKeyID( OUString& ouKeyID );
void setGpgCertificate( OUString& ouGpgCert ); void setGpgCertificate( OUString& ouGpgCert );
void setGpgOwner( OUString& ouGpgOwner );
void setDate( OUString& ouDate ); void setDate( OUString& ouDate );
void setDescription(const OUString& rDescription); void setDescription(const OUString& rDescription);
...@@ -388,7 +389,8 @@ public: ...@@ -388,7 +389,8 @@ public:
void setGpgCertificate( void setGpgCertificate(
sal_Int32 nSecurityId, sal_Int32 nSecurityId,
const OUString& ouCertDigest, const OUString& ouCertDigest,
const OUString& ouCert); const OUString& ouCert,
const OUString& ouOwner);
void setDate( void setDate(
sal_Int32 nSecurityId, sal_Int32 nSecurityId,
......
...@@ -537,7 +537,6 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() ...@@ -537,7 +537,6 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
const SignatureInformation& rInfo = maSignatureManager.maCurrentSignatureInformations[n]; const SignatureInformation& rInfo = maSignatureManager.maCurrentSignatureInformations[n];
uno::Reference< css::security::XCertificate > xCert = getCertificate(rInfo); uno::Reference< css::security::XCertificate > xCert = getCertificate(rInfo);
// TODO - should use pgpdata from info provider?
OUString aSubject; OUString aSubject;
OUString aIssuer; OUString aIssuer;
OUString aDateTimeStr; OUString aDateTimeStr;
...@@ -564,28 +563,34 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() ...@@ -564,28 +563,34 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
aSubject = XmlSec::GetContentPart( xCert->getSubjectName() ); aSubject = XmlSec::GetContentPart( xCert->getSubjectName() );
aIssuer = XmlSec::GetContentPart( xCert->getIssuerName() ); aIssuer = XmlSec::GetContentPart( xCert->getIssuerName() );
// String with date and time information (#i20172#) }
aDateTimeStr = XmlSec::GetDateTimeString( rInfo.stDateTime ); else if (!rInfo.ouGpgCertificate.isEmpty())
aDescription = rInfo.ouDescription; {
// In case we don't have the gpg key locally, get some data from the document
// Decide type string. aIssuer = rInfo.ouGpgOwner;
if (maSignatureManager.mxStore.is()) }
{
// XML based: XAdES or not. aDateTimeStr = XmlSec::GetDateTimeString( rInfo.stDateTime );
if (!rInfo.ouCertDigest.isEmpty()) aDescription = rInfo.ouDescription;
aType = "XAdES";
else // Decide type string.
aType = "XML-DSig"; if (maSignatureManager.mxStore.is())
} {
// XML based: XAdES or not.
if (!rInfo.ouCertDigest.isEmpty())
aType = "XAdES";
else else
{ aType = "XML-DSig";
// Assume PDF: PAdES or not.
if (rInfo.bHasSigningCertificate)
aType = "PAdES";
else
aType = "PDF";
}
} }
else
{
// Assume PDF: PAdES or not.
if (rInfo.bHasSigningCertificate)
aType = "PAdES";
else
aType = "PDF";
}
bSigValid = ( rInfo.nStatus == css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED ); bSigValid = ( rInfo.nStatus == css::xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED );
if ( bSigValid ) if ( bSigValid )
......
...@@ -291,7 +291,7 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>& ...@@ -291,7 +291,7 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
else else
SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one"); 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 else
{ {
......
...@@ -125,12 +125,14 @@ void XMLSignatureHelper::AddEncapsulatedX509Certificate(const OUString& ouEncaps ...@@ -125,12 +125,14 @@ void XMLSignatureHelper::AddEncapsulatedX509Certificate(const OUString& ouEncaps
void XMLSignatureHelper::SetGpgCertificate(sal_Int32 nSecurityId, void XMLSignatureHelper::SetGpgCertificate(sal_Int32 nSecurityId,
const OUString& ouGpgCertDigest, const OUString& ouGpgCertDigest,
const OUString& ouGpgCert) const OUString& ouGpgCert,
const OUString& ouGpgOwner)
{ {
mpXSecController->setGpgCertificate( mpXSecController->setGpgCertificate(
nSecurityId, nSecurityId,
ouGpgCertDigest, ouGpgCertDigest,
ouGpgCert); ouGpgCert,
ouGpgOwner);
} }
void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const ::Date& rDate, const tools::Time& rTime ) void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const ::Date& rDate, const tools::Time& rTime )
......
...@@ -747,6 +747,13 @@ void XSecController::exportSignature( ...@@ -747,6 +747,13 @@ void XSecController::exportSignature(
xDocumentHandler->characters( signatureInfo.ouGpgCertificate ); xDocumentHandler->characters( signatureInfo.ouGpgCertificate );
xDocumentHandler->endElement( "PGPKeyPacket" ); 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" ); xDocumentHandler->endElement( "PGPData" );
} }
......
...@@ -36,6 +36,7 @@ XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper, ...@@ -36,6 +36,7 @@ XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper,
, m_bInX509Certificate(false) , m_bInX509Certificate(false)
, m_bInGpgCertificate(false) , m_bInGpgCertificate(false)
, m_bInGpgKeyID(false) , m_bInGpgKeyID(false)
, m_bInGpgOwner(false)
, m_bInCertDigest(false) , m_bInCertDigest(false)
, m_bInEncapsulatedX509Certificate(false) , m_bInEncapsulatedX509Certificate(false)
, m_bInSigningTime(false) , m_bInSigningTime(false)
...@@ -72,6 +73,7 @@ void SAL_CALL XSecParser::startDocument( ) ...@@ -72,6 +73,7 @@ void SAL_CALL XSecParser::startDocument( )
m_bInX509Certificate = false; m_bInX509Certificate = false;
m_bInGpgCertificate = false; m_bInGpgCertificate = false;
m_bInGpgKeyID = false; m_bInGpgKeyID = false;
m_bInGpgOwner = false;
m_bInSignatureValue = false; m_bInSignatureValue = false;
m_bInDigestValue = false; m_bInDigestValue = false;
m_bInDate = false; m_bInDate = false;
...@@ -192,6 +194,11 @@ void SAL_CALL XSecParser::startElement( ...@@ -192,6 +194,11 @@ void SAL_CALL XSecParser::startElement(
m_ouGpgCertificate.clear(); m_ouGpgCertificate.clear();
m_bInGpgCertificate = true; m_bInGpgCertificate = true;
} }
else if (aName == "PGPOwner")
{
m_ouGpgOwner.clear();
m_bInGpgOwner = true;
}
else if (aName == "SignatureValue") else if (aName == "SignatureValue")
{ {
m_ouSignatureValue.clear(); m_ouSignatureValue.clear();
...@@ -315,6 +322,11 @@ void SAL_CALL XSecParser::endElement( const OUString& aName ) ...@@ -315,6 +322,11 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
m_pXSecController->setGpgCertificate( m_ouGpgCertificate ); m_pXSecController->setGpgCertificate( m_ouGpgCertificate );
m_bInGpgCertificate = false; m_bInGpgCertificate = false;
} }
else if (aName == "PGPOwner")
{
m_pXSecController->setGpgOwner( m_ouGpgOwner );
m_bInGpgOwner = false;
}
else if (aName == "xd:CertDigest") else if (aName == "xd:CertDigest")
{ {
m_pXSecController->setCertDigest( m_ouCertDigest ); m_pXSecController->setCertDigest( m_ouCertDigest );
...@@ -386,6 +398,10 @@ void SAL_CALL XSecParser::characters( const OUString& aChars ) ...@@ -386,6 +398,10 @@ void SAL_CALL XSecParser::characters( const OUString& aChars )
{ {
m_ouGpgKeyID += aChars; m_ouGpgKeyID += aChars;
} }
else if (m_bInGpgOwner)
{
m_ouGpgOwner += aChars;
}
else if (m_bInSignatureValue) else if (m_bInSignatureValue)
{ {
m_ouSignatureValue += aChars; m_ouSignatureValue += aChars;
......
...@@ -59,6 +59,7 @@ private: ...@@ -59,6 +59,7 @@ private:
OUString m_ouX509Certificate; OUString m_ouX509Certificate;
OUString m_ouGpgCertificate; OUString m_ouGpgCertificate;
OUString m_ouGpgKeyID; OUString m_ouGpgKeyID;
OUString m_ouGpgOwner;
OUString m_ouCertDigest; OUString m_ouCertDigest;
OUString m_ouEncapsulatedX509Certificate; OUString m_ouEncapsulatedX509Certificate;
OUString m_ouDigestValue; OUString m_ouDigestValue;
...@@ -75,6 +76,7 @@ private: ...@@ -75,6 +76,7 @@ private:
bool m_bInX509Certificate; bool m_bInX509Certificate;
bool m_bInGpgCertificate; bool m_bInGpgCertificate;
bool m_bInGpgKeyID; bool m_bInGpgKeyID;
bool m_bInGpgOwner;
bool m_bInCertDigest; bool m_bInCertDigest;
bool m_bInEncapsulatedX509Certificate; bool m_bInEncapsulatedX509Certificate;
bool m_bInSigningTime; bool m_bInSigningTime;
......
...@@ -242,7 +242,8 @@ void XSecController::setX509Certificate( ...@@ -242,7 +242,8 @@ void XSecController::setX509Certificate(
void XSecController::setGpgCertificate( void XSecController::setGpgCertificate(
sal_Int32 nSecurityId, sal_Int32 nSecurityId,
const OUString& ouCertDigest, const OUString& ouCertDigest,
const OUString& ouCert) const OUString& ouCert,
const OUString& ouOwner)
{ {
int index = findSignatureInfor( nSecurityId ); int index = findSignatureInfor( nSecurityId );
...@@ -250,6 +251,7 @@ void XSecController::setGpgCertificate( ...@@ -250,6 +251,7 @@ void XSecController::setGpgCertificate(
{ {
InternalSignatureInformation isi(nSecurityId, nullptr); InternalSignatureInformation isi(nSecurityId, nullptr);
isi.signatureInfor.ouGpgCertificate = ouCert; isi.signatureInfor.ouGpgCertificate = ouCert;
isi.signatureInfor.ouGpgOwner = ouOwner;
isi.signatureInfor.ouCertDigest = ouCertDigest; isi.signatureInfor.ouCertDigest = ouCertDigest;
m_vInternalSignatureInformations.push_back( isi ); m_vInternalSignatureInformations.push_back( isi );
} }
...@@ -258,6 +260,7 @@ void XSecController::setGpgCertificate( ...@@ -258,6 +260,7 @@ void XSecController::setGpgCertificate(
SignatureInformation &si SignatureInformation &si
= m_vInternalSignatureInformations[index].signatureInfor; = m_vInternalSignatureInformations[index].signatureInfor;
si.ouGpgCertificate = ouCert; si.ouGpgCertificate = ouCert;
si.ouGpgOwner = ouOwner;
si.ouCertDigest = ouCertDigest; si.ouCertDigest = ouCertDigest;
} }
} }
......
...@@ -294,6 +294,17 @@ void XSecController::setGpgCertificate( OUString& ouGpgCert ) ...@@ -294,6 +294,17 @@ void XSecController::setGpgCertificate( OUString& ouGpgCert )
isi.signatureInfor.ouGpgCertificate = 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 ) void XSecController::setDate( OUString& ouDate )
{ {
if (m_vInternalSignatureInformations.empty()) if (m_vInternalSignatureInformations.empty())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment