LibreOffice Module sfx2 (master) 1
signaturestate.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
11
12#include <com/sun/star/security/CertificateValidity.hpp>
13#include <com/sun/star/security/DocumentSignatureInformation.hpp>
14
15using namespace css;
16
18{
20getSignatureState(const uno::Sequence<security::DocumentSignatureInformation>& aSigInfo)
21{
22 bool bCertValid = true;
24 bool bCompleteSignature = true;
25 if (!aSigInfo.hasElements())
26 return nResult;
27
28 nResult = SignatureState::OK;
29 for (const auto& rInfo : aSigInfo)
30 {
31 if (bCertValid)
32 {
33 sal_Int32 nCertStat = rInfo.CertificateStatus;
34 bCertValid = nCertStat == security::CertificateValidity::VALID;
35 }
36
37 if (!rInfo.SignatureIsValid)
38 {
39 nResult = SignatureState::BROKEN;
40 break;
41 }
42 bCompleteSignature &= !rInfo.PartialDocumentSignature;
43 }
44
45 if (nResult == SignatureState::OK && !bCertValid && !bCompleteSignature)
47 else if (nResult == SignatureState::OK && !bCertValid)
49 else if (nResult == SignatureState::OK && bCertValid && !bCompleteSignature)
51
52 // this code must not check whether the document is modified
53 // it should only check the provided info
54
55 return nResult;
56}
57}
58
59/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
SignatureState getSignatureState(const uno::Sequence< security::DocumentSignatureInformation > &aSigInfo)
SignatureState
@ NOTVALIDATED_PARTIAL_OK
Certificate could not be validated and the document is only partially signed.