Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <xmlsecurity/certvalidity.hxx>
22 : #include <com/sun/star/security/CertificateValidity.hpp>
23 :
24 : using namespace ::com::sun::star::security ;
25 :
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"
43 :
44 0 : OUString certificateValidityToOUString( ::sal_Int32 certValidity ) {
45 0 : OUString aValidity ;
46 :
47 0 : if( certValidity == CertificateValidity::VALID ) {
48 0 : aValidity = VALID_STR;
49 0 : } else if( ( certValidity & CertificateValidity::UNTRUSTED ) == CertificateValidity::UNTRUSTED ) {
50 0 : aValidity = UNTRUSTED_STR;
51 0 : } else if( ( certValidity & CertificateValidity::TIME_INVALID ) == CertificateValidity::TIME_INVALID ) {
52 0 : aValidity = TIME_INVALID_STR;
53 0 : } else if( ( certValidity & CertificateValidity::NOT_TIME_NESTED ) == CertificateValidity::NOT_TIME_NESTED ) {
54 0 : aValidity = NOT_NESTED_TIME_STR;
55 0 : } else if( ( certValidity & CertificateValidity::REVOKED ) == CertificateValidity::REVOKED ) {
56 0 : aValidity = REVOKED_STR;
57 0 : } else if( ( certValidity & CertificateValidity::UNKNOWN_REVOKATION ) == CertificateValidity::UNKNOWN_REVOKATION ) {
58 0 : aValidity = UNKNOWN_REVOKATION_STR;
59 0 : } else if( ( certValidity & CertificateValidity::SIGNATURE_INVALID ) == CertificateValidity::SIGNATURE_INVALID ) {
60 0 : aValidity = SIGNATURE_INVALID_STR;
61 0 : } else if( ( certValidity & CertificateValidity::EXTENSION_INVALID ) == CertificateValidity::EXTENSION_INVALID ) {
62 0 : aValidity = EXTENSION_INVALID_STR;
63 0 : } else if( ( certValidity & CertificateValidity::EXTENSION_UNKNOWN ) == CertificateValidity::EXTENSION_UNKNOWN ) {
64 0 : aValidity = EXTENSION_UNKNOWN_STR;
65 0 : } else if( ( certValidity & CertificateValidity::ISSUER_UNKNOWN ) == CertificateValidity::ISSUER_UNKNOWN ) {
66 0 : aValidity = ISSUER_UNKNOWN_STR;
67 0 : } else if( ( certValidity & CertificateValidity::ISSUER_UNTRUSTED ) == CertificateValidity::ISSUER_UNTRUSTED ) {
68 0 : aValidity = ISSUER_UNTRUSTED_STR;
69 0 : } else if( ( certValidity & CertificateValidity::ISSUER_INVALID ) == CertificateValidity::ISSUER_INVALID ) {
70 0 : aValidity = ISSUER_INVALID_STR;
71 0 : } else if( ( certValidity & CertificateValidity::ROOT_UNKNOWN ) == CertificateValidity::ROOT_UNKNOWN ) {
72 0 : aValidity = ROOT_UNKNOWN_STR;
73 0 : } else if( ( certValidity & CertificateValidity::ROOT_UNTRUSTED ) == CertificateValidity::ROOT_UNTRUSTED ) {
74 0 : aValidity = ROOT_UNTRUSTED_STR;
75 0 : } else if( ( certValidity & CertificateValidity::ROOT_INVALID ) == CertificateValidity::ROOT_INVALID ) {
76 0 : aValidity = ROOT_INVALID_STR;
77 0 : } else if( ( certValidity & CertificateValidity::CHAIN_INCOMPLETE ) == CertificateValidity::CHAIN_INCOMPLETE ) {
78 0 : aValidity = CHAIN_INCOMPLETE_STR;
79 : } else {
80 0 : aValidity = INVALID_STR;
81 : }
82 :
83 0 : return aValidity ;
84 : }
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|