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 ::rtl::OUString ;
25 : using namespace ::com::sun::star::security ;
26 :
27 : #define VALID_STR "valid certificate"
28 : #define INVALID_STR "invalid certificate"
29 : #define UNTRUSTED_STR "untrusted certificate"
30 : #define TIME_INVALID_STR "expired certificate"
31 : #define NOT_NESTED_TIME_STR "invalid time nesting"
32 : #define REVOKED_STR "revoked certificate"
33 : #define UNKNOWN_REVOKATION_STR "unknown certificate revocation status"
34 : #define SIGNATURE_INVALID_STR "invalid certificate signature"
35 : #define EXTENSION_INVALID_STR "invalid certificate extension"
36 : #define EXTENSION_UNKNOWN_STR "unknown critical certificate extension"
37 : #define ISSUER_UNKNOWN_STR "unknown certificate issuer"
38 : #define ISSUER_UNTRUSTED_STR "untrusted certificate issuer"
39 : #define ISSUER_INVALID_STR "invalid certificate issuer"
40 : #define ROOT_UNKNOWN_STR "unknown root certificate"
41 : #define ROOT_UNTRUSTED_STR "untrusted root certificate"
42 : #define ROOT_INVALID_STR "invalid root certificate"
43 : #define CHAIN_INCOMPLETE_STR "invalid certification path"
44 :
45 0 : rtl::OUString certificateValidityToOUString( ::sal_Int32 certValidity ) {
46 0 : OUString aValidity ;
47 :
48 : if( (certValidity & CertificateValidity::VALID) == CertificateValidity::VALID ) {
49 0 : aValidity = OUString(VALID_STR ) ;
50 : } else if( ( certValidity & CertificateValidity::INVALID ) == CertificateValidity::INVALID ) {
51 : aValidity = OUString(INVALID_STR ) ;
52 : } else if( ( certValidity & CertificateValidity::UNTRUSTED ) == CertificateValidity::UNTRUSTED ) {
53 : aValidity = OUString(UNTRUSTED_STR ) ;
54 : } else if( ( certValidity & CertificateValidity::TIME_INVALID ) == CertificateValidity::TIME_INVALID ) {
55 : aValidity = OUString(TIME_INVALID_STR ) ;
56 : } else if( ( certValidity & CertificateValidity::NOT_TIME_NESTED ) == CertificateValidity::NOT_TIME_NESTED ) {
57 : aValidity = OUString(NOT_NESTED_TIME_STR ) ;
58 : } else if( ( certValidity & CertificateValidity::REVOKED ) == CertificateValidity::REVOKED ) {
59 : aValidity = OUString(REVOKED_STR ) ;
60 : } else if( ( certValidity & CertificateValidity::UNKNOWN_REVOKATION ) == CertificateValidity::UNKNOWN_REVOKATION ) {
61 : aValidity = OUString(UNKNOWN_REVOKATION_STR ) ;
62 : } else if( ( certValidity & CertificateValidity::SIGNATURE_INVALID ) == CertificateValidity::SIGNATURE_INVALID ) {
63 : aValidity = OUString(SIGNATURE_INVALID_STR ) ;
64 : } else if( ( certValidity & CertificateValidity::EXTENSION_INVALID ) == CertificateValidity::EXTENSION_INVALID ) {
65 : aValidity = OUString(EXTENSION_INVALID_STR ) ;
66 : } else if( ( certValidity & CertificateValidity::EXTENSION_UNKNOWN ) == CertificateValidity::EXTENSION_UNKNOWN ) {
67 : aValidity = OUString(EXTENSION_UNKNOWN_STR ) ;
68 : } else if( ( certValidity & CertificateValidity::ISSUER_UNKNOWN ) == CertificateValidity::ISSUER_UNKNOWN ) {
69 : aValidity = OUString(ISSUER_UNKNOWN_STR ) ;
70 : } else if( ( certValidity & CertificateValidity::ISSUER_UNTRUSTED ) == CertificateValidity::ISSUER_UNTRUSTED ) {
71 : aValidity = OUString(ISSUER_UNTRUSTED_STR ) ;
72 : } else if( ( certValidity & CertificateValidity::ISSUER_INVALID ) == CertificateValidity::ISSUER_INVALID ) {
73 : aValidity = OUString(ISSUER_INVALID_STR ) ;
74 : } else if( ( certValidity & CertificateValidity::ROOT_UNKNOWN ) == CertificateValidity::ROOT_UNKNOWN ) {
75 : aValidity = OUString(ROOT_UNKNOWN_STR ) ;
76 : } else if( ( certValidity & CertificateValidity::ROOT_UNTRUSTED ) == CertificateValidity::ROOT_UNTRUSTED ) {
77 : aValidity = OUString(ROOT_UNTRUSTED_STR ) ;
78 : } else if( ( certValidity & CertificateValidity::ROOT_INVALID ) == CertificateValidity::ROOT_INVALID ) {
79 : aValidity = OUString(ROOT_INVALID_STR ) ;
80 : } else if( ( certValidity & CertificateValidity::CHAIN_INCOMPLETE ) == CertificateValidity::CHAIN_INCOMPLETE ) {
81 : aValidity = OUString(CHAIN_INCOMPLETE_STR ) ;
82 : } else {
83 : aValidity = OUString(INVALID_STR ) ;
84 : }
85 :
86 0 : return aValidity ;
87 : }
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|