1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sfx2/signaturestate.hxx>
12 #include <com/sun/star/security/CertificateValidity.hpp>
13 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
17 namespace DocumentSignatures
20 getSignatureState(const uno::Sequence
<security::DocumentSignatureInformation
>& aSigInfo
)
22 bool bCertValid
= true;
23 SignatureState nResult
= SignatureState::NOSIGNATURES
;
24 bool bCompleteSignature
= true;
25 if (!aSigInfo
.hasElements())
28 nResult
= SignatureState::OK
;
29 for (const auto& rInfo
: aSigInfo
)
33 sal_Int32 nCertStat
= rInfo
.CertificateStatus
;
34 bCertValid
= nCertStat
== security::CertificateValidity::VALID
;
37 if (!rInfo
.SignatureIsValid
)
39 nResult
= SignatureState::BROKEN
;
42 bCompleteSignature
&= !rInfo
.PartialDocumentSignature
;
45 if (nResult
== SignatureState::OK
&& !bCertValid
&& !bCompleteSignature
)
46 nResult
= SignatureState::NOTVALIDATED_PARTIAL_OK
;
47 else if (nResult
== SignatureState::OK
&& !bCertValid
)
48 nResult
= SignatureState::NOTVALIDATED
;
49 else if (nResult
== SignatureState::OK
&& bCertValid
&& !bCompleteSignature
)
50 nResult
= SignatureState::PARTIAL_OK
;
52 // this code must not check whether the document is modified
53 // it should only check the provided info
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */