merged tag ooo/OOO330_m14
[LibreOffice.git] / xmlsecurity / source / xmlsec / mscrypt / securityenvironment_mscryptimpl.hxx
bloba97c96b6c3d336492617ddfc33deaf9f0cba5a45
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_
29 #define _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_
31 #ifdef _MSC_VER
32 #pragma warning(push,1)
33 #endif
34 #include <windows.h>
35 #include <wincrypt.h>
36 #ifdef _MSC_VER
37 #pragma warning(pop)
38 #endif
39 #include <sal/config.h>
40 #include <rtl/ustring.hxx>
41 #include <cppuhelper/factory.hxx>
42 #include <cppuhelper/implbase4.hxx>
43 #include <com/sun/star/uno/Exception.hpp>
45 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
46 #include <com/sun/star/uno/Reference.hxx>
47 #endif
48 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
50 #ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #endif
53 #include <com/sun/star/lang/XInitialization.hpp>
54 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
55 #include <com/sun/star/security/XCertificate.hpp>
56 #include <com/sun/star/security/CertificateCharacters.hpp>
57 #include <com/sun/star/security/CertificateValidity.hpp>
58 #include <com/sun/star/lang/XUnoTunnel.hpp>
60 #include <list>
61 #include "xmlsec/xmlsec.h"
63 class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper4<
64 ::com::sun::star::xml::crypto::XSecurityEnvironment ,
65 ::com::sun::star::lang::XInitialization ,
66 ::com::sun::star::lang::XServiceInfo ,
67 ::com::sun::star::lang::XUnoTunnel >
69 private :
70 //cyrpto provider and key container
71 HCRYPTPROV m_hProv ;
72 LPCTSTR m_pszContainer ;
74 //Key store
75 HCERTSTORE m_hKeyStore ;
77 //Certiticate store
78 HCERTSTORE m_hCertStore ;
80 //Enable default system cryptography setting
81 sal_Bool m_bEnableDefault ;
83 //External keys
84 std::list< HCRYPTKEY > m_tSymKeyList ;
85 std::list< HCRYPTKEY > m_tPubKeyList ;
86 std::list< HCRYPTKEY > m_tPriKeyList ;
88 //Service manager
89 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ;
91 public :
92 SecurityEnvironment_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ;
93 virtual ~SecurityEnvironment_MSCryptImpl() ;
95 //Methods from XSecurityEnvironment
96 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 ) ;
98 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 ) ;
100 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 ) ;
102 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 ) ;
104 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 ) ;
106 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 ) ;
108 virtual ::sal_Int32 SAL_CALL verifyCertificate(
109 const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& xCert,
110 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
111 ::com::sun::star::security::XCertificate > >& intermediateCertificates)
112 throw (::com::sun::star::uno::SecurityException, ::com::sun::star::uno::RuntimeException) ;
113 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) ;
115 virtual ::rtl::OUString SAL_CALL getSecurityEnvironmentInformation( ) throw (::com::sun::star::uno::RuntimeException);
118 //Methods from XInitialization
119 virtual void SAL_CALL initialize(
120 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments
121 ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
123 //Methods from XServiceInfo
124 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
126 virtual sal_Bool SAL_CALL supportsService(
127 const ::rtl::OUString& ServiceName
128 ) throw( ::com::sun::star::uno::RuntimeException ) ;
130 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ;
132 //Helper for XServiceInfo
133 static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ;
135 static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
137 //Helper for registry
138 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 ) ;
140 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 ) ;
142 //Methods from XUnoTunnel
143 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
144 throw (::com::sun::star::uno::RuntimeException);
146 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
147 static SecurityEnvironment_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ;
149 //Native mehtods
150 virtual HCRYPTPROV getCryptoProvider() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
152 virtual void setCryptoProvider( HCRYPTPROV aProv ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
154 virtual LPCTSTR getKeyContainer() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
156 virtual void setKeyContainer( LPCTSTR aKeyContainer ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
158 virtual HCERTSTORE getCryptoSlot() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
160 virtual void setCryptoSlot( HCERTSTORE aKeyStore ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
162 virtual HCERTSTORE getCertDb() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
164 virtual void setCertDb( HCERTSTORE aCertDb ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
166 virtual void adoptSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
168 virtual void rejectSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
170 virtual HCRYPTKEY getSymKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
172 virtual void adoptPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
174 virtual void rejectPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
176 virtual HCRYPTKEY getPubKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
178 virtual void adoptPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
180 virtual void rejectPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
182 virtual HCRYPTKEY getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
184 virtual void enableDefaultCrypt( sal_Bool enable ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
186 virtual sal_Bool defaultEnabled() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
188 //Native mehtods
189 virtual xmlSecKeysMngrPtr createKeysManager() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
191 virtual void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
194 #endif // _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_