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