Kaydet (Commit) 4a59a8ab authored tarafından Miklos Vajna's avatar Miklos Vajna

sfx2: show partial signatures even if cert validation fails

Change-Id: I6060b7130827346ac5d6955bf38ebe3b476819fd
Reviewed-on: https://gerrit.libreoffice.org/64022
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 12d0c067
......@@ -33,7 +33,9 @@ enum class SignatureState
NOTVALIDATED = 4,
// signature and certificate are ok, but not all files are signed, as it was the case in
// OOo 2.x - OOo 3.1.1. This state is only used together with document signatures.
PARTIAL_OK = 5
PARTIAL_OK = 5,
/// Certificate could not be validated and the document is only partially signed.
NOTVALIDATED_PARTIAL_OK = 6
};
#endif // INCLUDED_SFX2_SIGNATURESTATE_HXX
......
......@@ -261,6 +261,7 @@
#define STR_SIGNATURE_INVALID NC_("STR_SIGNATURE_INVALID", "The signature was valid, but the document has been modified")
#define STR_SIGNATURE_NOTVALIDATED NC_("STR_SIGNATURE_NOTVALIDATED", "The signature is OK, but the certificate could not be validated.")
#define STR_SIGNATURE_PARTIAL_OK NC_("STR_SIGNATURE_PARTIAL_OK", "The signature is OK, but the document is only partially signed.")
#define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.")
#define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.")
#define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures")
......
......@@ -1068,6 +1068,10 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
sMessage = SfxResId(STR_SIGNATURE_OK);
aInfoBarType = InfoBarType::Info;
break;
case SignatureState::NOTVALIDATED_PARTIAL_OK:
sMessage = SfxResId(STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK);
aInfoBarType = InfoBarType::Warning;
break;
//FIXME SignatureState::Unknown, own message?
default:
break;
......@@ -1285,7 +1289,9 @@ SignatureState SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequen
}
}
if ( nResult == SignatureState::OK && !bCertValid )
if (nResult == SignatureState::OK && !bCertValid && !bCompleteSignature)
nResult = SignatureState::NOTVALIDATED_PARTIAL_OK;
else if (nResult == SignatureState::OK && !bCertValid)
nResult = SignatureState::NOTVALIDATED;
else if ( nResult == SignatureState::OK && bCertValid && !bCompleteSignature)
nResult = SignatureState::PARTIAL_OK;
......
......@@ -639,12 +639,14 @@ void SigningTest::testOOXMLPartial()
SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
CPPUNIT_ASSERT(pObjectShell);
// This was SignatureState::BROKEN due to missing RelationshipTransform and SHA-256 support.
// We expect NOTVALIDATED in case the root CA is not imported on the system, and PARTIAL_OK otherwise, so accept both.
// We expect NOTVALIDATED_PARTIAL_OK in case the root CA is not imported on the system, and PARTIAL_OK otherwise, so accept both.
// But reject NOTVALIDATED, hiding incompleteness is not OK.
SignatureState nActual = pObjectShell->GetDocumentSignatureState();
CPPUNIT_ASSERT_MESSAGE(
(OString::number(static_cast<std::underlying_type<SignatureState>::type>(nActual))
.getStr()),
(nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::PARTIAL_OK));
(nActual == SignatureState::NOTVALIDATED_PARTIAL_OK
|| nActual == SignatureState::PARTIAL_OK));
}
void SigningTest::testOOXMLBroken()
......
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