1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <xmlsecurity/certvalidity.hxx>
22 #include <com/sun/star/security/CertificateValidity.hpp>
24 using namespace ::com::sun::star::security
;
26 #define VALID_STR "valid certificate"
27 #define INVALID_STR "invalid certificate"
28 #define UNTRUSTED_STR "untrusted certificate"
29 #define TIME_INVALID_STR "expired certificate"
30 #define NOT_NESTED_TIME_STR "invalid time nesting"
31 #define REVOKED_STR "revoked certificate"
32 #define UNKNOWN_REVOKATION_STR "unknown certificate revocation status"
33 #define SIGNATURE_INVALID_STR "invalid certificate signature"
34 #define EXTENSION_INVALID_STR "invalid certificate extension"
35 #define EXTENSION_UNKNOWN_STR "unknown critical certificate extension"
36 #define ISSUER_UNKNOWN_STR "unknown certificate issuer"
37 #define ISSUER_UNTRUSTED_STR "untrusted certificate issuer"
38 #define ISSUER_INVALID_STR "invalid certificate issuer"
39 #define ROOT_UNKNOWN_STR "unknown root certificate"
40 #define ROOT_UNTRUSTED_STR "untrusted root certificate"
41 #define ROOT_INVALID_STR "invalid root certificate"
42 #define CHAIN_INCOMPLETE_STR "invalid certification path"
44 OUString
certificateValidityToOUString( ::sal_Int32 certValidity
) {
47 if( certValidity
== CertificateValidity::VALID
) {
48 aValidity
= VALID_STR
;
49 } else if( ( certValidity
& CertificateValidity::UNTRUSTED
) == CertificateValidity::UNTRUSTED
) {
50 aValidity
= UNTRUSTED_STR
;
51 } else if( ( certValidity
& CertificateValidity::TIME_INVALID
) == CertificateValidity::TIME_INVALID
) {
52 aValidity
= TIME_INVALID_STR
;
53 } else if( ( certValidity
& CertificateValidity::NOT_TIME_NESTED
) == CertificateValidity::NOT_TIME_NESTED
) {
54 aValidity
= NOT_NESTED_TIME_STR
;
55 } else if( ( certValidity
& CertificateValidity::REVOKED
) == CertificateValidity::REVOKED
) {
56 aValidity
= REVOKED_STR
;
57 } else if( ( certValidity
& CertificateValidity::UNKNOWN_REVOKATION
) == CertificateValidity::UNKNOWN_REVOKATION
) {
58 aValidity
= UNKNOWN_REVOKATION_STR
;
59 } else if( ( certValidity
& CertificateValidity::SIGNATURE_INVALID
) == CertificateValidity::SIGNATURE_INVALID
) {
60 aValidity
= SIGNATURE_INVALID_STR
;
61 } else if( ( certValidity
& CertificateValidity::EXTENSION_INVALID
) == CertificateValidity::EXTENSION_INVALID
) {
62 aValidity
= EXTENSION_INVALID_STR
;
63 } else if( ( certValidity
& CertificateValidity::EXTENSION_UNKNOWN
) == CertificateValidity::EXTENSION_UNKNOWN
) {
64 aValidity
= EXTENSION_UNKNOWN_STR
;
65 } else if( ( certValidity
& CertificateValidity::ISSUER_UNKNOWN
) == CertificateValidity::ISSUER_UNKNOWN
) {
66 aValidity
= ISSUER_UNKNOWN_STR
;
67 } else if( ( certValidity
& CertificateValidity::ISSUER_UNTRUSTED
) == CertificateValidity::ISSUER_UNTRUSTED
) {
68 aValidity
= ISSUER_UNTRUSTED_STR
;
69 } else if( ( certValidity
& CertificateValidity::ISSUER_INVALID
) == CertificateValidity::ISSUER_INVALID
) {
70 aValidity
= ISSUER_INVALID_STR
;
71 } else if( ( certValidity
& CertificateValidity::ROOT_UNKNOWN
) == CertificateValidity::ROOT_UNKNOWN
) {
72 aValidity
= ROOT_UNKNOWN_STR
;
73 } else if( ( certValidity
& CertificateValidity::ROOT_UNTRUSTED
) == CertificateValidity::ROOT_UNTRUSTED
) {
74 aValidity
= ROOT_UNTRUSTED_STR
;
75 } else if( ( certValidity
& CertificateValidity::ROOT_INVALID
) == CertificateValidity::ROOT_INVALID
) {
76 aValidity
= ROOT_INVALID_STR
;
77 } else if( ( certValidity
& CertificateValidity::CHAIN_INCOMPLETE
) == CertificateValidity::CHAIN_INCOMPLETE
) {
78 aValidity
= CHAIN_INCOMPLETE_STR
;
80 aValidity
= INVALID_STR
;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */