1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: certvalidity.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 #include <xmlsecurity/certvalidity.hxx>
35 #include <com/sun/star/security/CertificateValidity.hpp>
37 using ::rtl::OUString
;
38 using namespace ::com::sun::star::security
;
40 #define VALID_STR "valid certificate"
41 #define INVALID_STR "invalid certificate"
42 #define UNTRUSTED_STR "untrusted certificate"
43 #define TIME_INVALID_STR "expired certificate"
44 #define NOT_NESTED_TIME_STR "invalid time nesting"
45 #define REVOKED_STR "revoked certificate"
46 #define UNKNOWN_REVOKATION_STR "unknown certificate revocation status"
47 #define SIGNATURE_INVALID_STR "invalid certificate signature"
48 #define EXTENSION_INVALID_STR "invalid certificate extension"
49 #define EXTENSION_UNKNOWN_STR "unknown critical certificate extension"
50 #define ISSUER_UNKNOWN_STR "unknown certificate issuer"
51 #define ISSUER_UNTRUSTED_STR "untrusted certificate issuer"
52 #define ISSUER_INVALID_STR "invalid certificate issuer"
53 #define ROOT_UNKNOWN_STR "unknown root certificate"
54 #define ROOT_UNTRUSTED_STR "untrusted root certificate"
55 #define ROOT_INVALID_STR "invalid root certificate"
56 #define CHAIN_INCOMPLETE_STR "invalid certification path"
58 rtl::OUString
certificateValidityToOUString( ::sal_Int32 certValidity
) {
61 if( (certValidity
& CertificateValidity::VALID
) == CertificateValidity::VALID
) {
62 aValidity
= OUString::createFromAscii( ( const char* )VALID_STR
) ;
63 } else if( ( certValidity
& CertificateValidity::INVALID
) == CertificateValidity::INVALID
) {
64 aValidity
= OUString::createFromAscii( ( const char* )INVALID_STR
) ;
65 } else if( ( certValidity
& CertificateValidity::UNTRUSTED
) == CertificateValidity::UNTRUSTED
) {
66 aValidity
= OUString::createFromAscii( ( const char* )UNTRUSTED_STR
) ;
67 } else if( ( certValidity
& CertificateValidity::TIME_INVALID
) == CertificateValidity::TIME_INVALID
) {
68 aValidity
= OUString::createFromAscii( ( const char* )TIME_INVALID_STR
) ;
69 } else if( ( certValidity
& CertificateValidity::NOT_TIME_NESTED
) == CertificateValidity::NOT_TIME_NESTED
) {
70 aValidity
= OUString::createFromAscii( ( const char* )NOT_NESTED_TIME_STR
) ;
71 } else if( ( certValidity
& CertificateValidity::REVOKED
) == CertificateValidity::REVOKED
) {
72 aValidity
= OUString::createFromAscii( ( const char* )REVOKED_STR
) ;
73 } else if( ( certValidity
& CertificateValidity::UNKNOWN_REVOKATION
) == CertificateValidity::UNKNOWN_REVOKATION
) {
74 aValidity
= OUString::createFromAscii( ( const char* )UNKNOWN_REVOKATION_STR
) ;
75 } else if( ( certValidity
& CertificateValidity::SIGNATURE_INVALID
) == CertificateValidity::SIGNATURE_INVALID
) {
76 aValidity
= OUString::createFromAscii( ( const char* )SIGNATURE_INVALID_STR
) ;
77 } else if( ( certValidity
& CertificateValidity::EXTENSION_INVALID
) == CertificateValidity::EXTENSION_INVALID
) {
78 aValidity
= OUString::createFromAscii( ( const char* )EXTENSION_INVALID_STR
) ;
79 } else if( ( certValidity
& CertificateValidity::EXTENSION_UNKNOWN
) == CertificateValidity::EXTENSION_UNKNOWN
) {
80 aValidity
= OUString::createFromAscii( ( const char* )EXTENSION_UNKNOWN_STR
) ;
81 } else if( ( certValidity
& CertificateValidity::ISSUER_UNKNOWN
) == CertificateValidity::ISSUER_UNKNOWN
) {
82 aValidity
= OUString::createFromAscii( ( const char* )ISSUER_UNKNOWN_STR
) ;
83 } else if( ( certValidity
& CertificateValidity::ISSUER_UNTRUSTED
) == CertificateValidity::ISSUER_UNTRUSTED
) {
84 aValidity
= OUString::createFromAscii( ( const char* )ISSUER_UNTRUSTED_STR
) ;
85 } else if( ( certValidity
& CertificateValidity::ISSUER_INVALID
) == CertificateValidity::ISSUER_INVALID
) {
86 aValidity
= OUString::createFromAscii( ( const char* )ISSUER_INVALID_STR
) ;
87 } else if( ( certValidity
& CertificateValidity::ROOT_UNKNOWN
) == CertificateValidity::ROOT_UNKNOWN
) {
88 aValidity
= OUString::createFromAscii( ( const char* )ROOT_UNKNOWN_STR
) ;
89 } else if( ( certValidity
& CertificateValidity::ROOT_UNTRUSTED
) == CertificateValidity::ROOT_UNTRUSTED
) {
90 aValidity
= OUString::createFromAscii( ( const char* )ROOT_UNTRUSTED_STR
) ;
91 } else if( ( certValidity
& CertificateValidity::ROOT_INVALID
) == CertificateValidity::ROOT_INVALID
) {
92 aValidity
= OUString::createFromAscii( ( const char* )ROOT_INVALID_STR
) ;
93 } else if( ( certValidity
& CertificateValidity::CHAIN_INCOMPLETE
) == CertificateValidity::CHAIN_INCOMPLETE
) {
94 aValidity
= OUString::createFromAscii( ( const char* )CHAIN_INCOMPLETE_STR
) ;
96 aValidity
= OUString::createFromAscii( ( const char* )INVALID_STR
) ;