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: securityenvironment_nssimpl.hxx,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 #ifndef _XSECURITYENVIRONMENT_NSSIMPL_HXX_
32 #define _XSECURITYENVIRONMENT_NSSIMPL_HXX_
34 #include <sal/config.h>
35 #include <rtl/ustring.hxx>
36 #include <cppuhelper/factory.hxx>
37 #include <cppuhelper/implbase4.hxx>
38 #include <com/sun/star/uno/Exception.hpp>
40 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
41 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_
46 #include <com/sun/star/lang/XServiceInfo.hpp>
48 #include <com/sun/star/lang/XInitialization.hpp>
49 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
50 #include <com/sun/star/security/XCertificate.hpp>
51 #include <com/sun/star/security/CertificateCharacters.hpp>
52 #include <com/sun/star/security/CertificateValidity.hpp>
53 #include <com/sun/star/lang/XUnoTunnel.hpp>
55 #include "osl/mutex.hxx"
62 #include <sal/types.h>
63 //For reasons that escape me, this is what xmlsec does when size_t is not 4
64 #if SAL_TYPES_SIZEOFPOINTER != 4
65 # define XMLSEC_NO_SIZE_T
67 #include "xmlsec/xmlsec.h"
69 class SecurityEnvironment_NssImpl
: public ::cppu::WeakImplHelper4
<
70 ::com::sun::star::xml::crypto::XSecurityEnvironment
,
71 ::com::sun::star::lang::XInitialization
,
72 ::com::sun::star::lang::XServiceInfo
,
73 ::com::sun::star::lang::XUnoTunnel
>
77 std::list
< PK11SlotInfo
* > m_Slots
;
78 typedef std::list
< PK11SlotInfo
* >::const_iterator CIT_SLOTS
;
82 CERTCertDBHandle
* m_pHandler
;
83 std::list
< PK11SymKey
* > m_tSymKeyList
;
84 std::list
< SECKEYPublicKey
* > m_tPubKeyList
;
85 std::list
< SECKEYPrivateKey
* > m_tPriKeyList
;
86 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceManager
;
89 SecurityEnvironment_NssImpl( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& aFactory
) ;
90 virtual ~SecurityEnvironment_NssImpl() ;
92 //Methods from XSecurityEnvironment
94 //Methods from XInitialization
95 virtual void SAL_CALL
initialize(
96 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
97 ) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
99 //Methods from XServiceInfo
100 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
) ;
102 virtual sal_Bool SAL_CALL
supportsService(
103 const ::rtl::OUString
& ServiceName
104 ) throw( ::com::sun::star::uno::RuntimeException
) ;
106 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
) ;
108 //Helper for XServiceInfo
109 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> impl_getSupportedServiceNames() ;
111 static ::rtl::OUString
impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException
) ;
113 //Helper for registry
114 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
impl_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& aServiceManager
) throw( ::com::sun::star::uno::RuntimeException
) ;
116 static ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleServiceFactory
> impl_createFactory( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& aServiceManager
) ;
118 virtual ::sal_Int32 SAL_CALL
verifyCertificate(
119 const ::com::sun::star::uno::Reference
<
120 ::com::sun::star::security::XCertificate
>& xCert
,
121 const ::com::sun::star::uno::Sequence
<
122 ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> > &
124 throw (::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
126 virtual ::sal_Int32 SAL_CALL
getCertificateCharacters( const ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
>& xCert
) throw (::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
128 virtual ::rtl::OUString SAL_CALL
getSecurityEnvironmentInformation( ) throw (::com::sun::star::uno::RuntimeException
);
130 //Methods from XUnoTunnel
131 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
)
132 throw (::com::sun::star::uno::RuntimeException
);
134 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelId() ;
135 static SecurityEnvironment_NssImpl
* getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xObj
) ;
138 virtual CERTCertDBHandle
* getCertDb() throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
140 virtual void setCertDb( CERTCertDBHandle
* aCertDb
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
142 virtual void adoptSymKey( PK11SymKey
* aSymKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
144 virtual void rejectSymKey( PK11SymKey
* aSymKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
146 virtual PK11SymKey
* getSymKey( unsigned int position
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
148 virtual void adoptPubKey( SECKEYPublicKey
* aPubKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
150 virtual void rejectPubKey( SECKEYPublicKey
* aPubKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
152 virtual SECKEYPublicKey
* getPubKey( unsigned int position
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
154 virtual void adoptPriKey( SECKEYPrivateKey
* aPriKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
156 virtual void rejectPriKey( SECKEYPrivateKey
* aPriKey
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
158 virtual SECKEYPrivateKey
* getPriKey( unsigned int position
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
160 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> > SAL_CALL
getPersonalCertificates() throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
162 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> SAL_CALL
getCertificate( const ::rtl::OUString
& issuerName
, const ::com::sun::star::uno::Sequence
< sal_Int8
>& serialNumber
) throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> SAL_CALL
getCertificate( const ::rtl::OUString
& issuerName
, const ::rtl::OUString
& serialNumber
) throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
166 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> > SAL_CALL
buildCertificatePath( const ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
>& beginCert
) throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
168 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> SAL_CALL
createCertificateFromRaw( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rawCertificate
) throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
170 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::security::XCertificate
> SAL_CALL
createCertificateFromAscii( const ::rtl::OUString
& asciiCertificate
) throw( ::com::sun::star::uno::SecurityException
, ::com::sun::star::uno::RuntimeException
) ;
174 virtual xmlSecKeysMngrPtr
createKeysManager() throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
175 virtual void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
180 virtual void addCryptoSlot( PK11SlotInfo
* aSlot
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
185 #endif // _XSECURITYENVIRONMENT_NSSIMPL_HXX_