Update ooo320-m1
[ooovba.git] / xmlsecurity / source / xmlsec / mscrypt / securityenvironment_mscryptimpl.hxx
blob913291dd5bdf2081cb07ca7a8aba00794eac1986
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: securityenvironment_mscryptimpl.hxx,v $
10 * $Revision: 1.9 $
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_MSCRYPTIMPL_HXX_
32 #define _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_
34 #ifdef _MSC_VER
35 #pragma warning(push,1)
36 #endif
37 #include <windows.h>
38 #include <wincrypt.h>
39 #ifdef _MSC_VER
40 #pragma warning(pop)
41 #endif
42 #include <sal/config.h>
43 #include <rtl/ustring.hxx>
44 #include <cppuhelper/factory.hxx>
45 #include <cppuhelper/implbase4.hxx>
46 #include <com/sun/star/uno/Exception.hpp>
48 #ifndef _COM_SUN_STAR_UNO_REFERENCE_HPP_
49 #include <com/sun/star/uno/Reference.hxx>
50 #endif
51 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
53 #ifndef _COM_SUN_STAR_LANG_XSECVICEINFO_HPP_
54 #include <com/sun/star/lang/XServiceInfo.hpp>
55 #endif
56 #include <com/sun/star/lang/XInitialization.hpp>
57 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
58 #include <com/sun/star/security/XCertificate.hpp>
59 #include <com/sun/star/security/CertificateCharacters.hpp>
60 #include <com/sun/star/security/CertificateValidity.hpp>
61 #include <com/sun/star/lang/XUnoTunnel.hpp>
63 #include <list>
64 #include "xmlsec/xmlsec.h"
66 class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper4<
67 ::com::sun::star::xml::crypto::XSecurityEnvironment ,
68 ::com::sun::star::lang::XInitialization ,
69 ::com::sun::star::lang::XServiceInfo ,
70 ::com::sun::star::lang::XUnoTunnel >
72 private :
73 //cyrpto provider and key container
74 HCRYPTPROV m_hProv ;
75 LPCTSTR m_pszContainer ;
77 //Key store
78 HCERTSTORE m_hKeyStore ;
80 //Certiticate store
81 HCERTSTORE m_hCertStore ;
83 //Enable default system cryptography setting
84 sal_Bool m_bEnableDefault ;
86 //External keys
87 std::list< HCRYPTKEY > m_tSymKeyList ;
88 std::list< HCRYPTKEY > m_tPubKeyList ;
89 std::list< HCRYPTKEY > m_tPriKeyList ;
91 //Service manager
92 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ;
94 public :
95 SecurityEnvironment_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ;
96 virtual ~SecurityEnvironment_MSCryptImpl() ;
98 //Methods from XSecurityEnvironment
99 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 ) ;
101 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 ) ;
103 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 ) ;
105 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 ) ;
107 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 ) ;
109 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 ) ;
111 virtual ::sal_Int32 SAL_CALL verifyCertificate(
112 const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& xCert,
113 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
114 ::com::sun::star::security::XCertificate > >& intermediateCertificates)
115 throw (::com::sun::star::uno::SecurityException, ::com::sun::star::uno::RuntimeException) ;
116 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) ;
118 virtual ::rtl::OUString SAL_CALL getSecurityEnvironmentInformation( ) throw (::com::sun::star::uno::RuntimeException);
121 //Methods from XInitialization
122 virtual void SAL_CALL initialize(
123 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments
124 ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
126 //Methods from XServiceInfo
127 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
129 virtual sal_Bool SAL_CALL supportsService(
130 const ::rtl::OUString& ServiceName
131 ) throw( ::com::sun::star::uno::RuntimeException ) ;
133 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ;
135 //Helper for XServiceInfo
136 static ::com::sun::star::uno::Sequence< ::rtl::OUString > impl_getSupportedServiceNames() ;
138 static ::rtl::OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
140 //Helper for registry
141 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 ) ;
143 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 ) ;
145 //Methods from XUnoTunnel
146 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
147 throw (::com::sun::star::uno::RuntimeException);
149 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
150 static SecurityEnvironment_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ;
152 //Native mehtods
153 virtual HCRYPTPROV getCryptoProvider() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
155 virtual void setCryptoProvider( HCRYPTPROV aProv ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
157 virtual LPCTSTR getKeyContainer() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
159 virtual void setKeyContainer( LPCTSTR aKeyContainer ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
161 virtual HCERTSTORE getCryptoSlot() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
163 virtual void setCryptoSlot( HCERTSTORE aKeyStore ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
165 virtual HCERTSTORE getCertDb() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
167 virtual void setCertDb( HCERTSTORE aCertDb ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
169 virtual void adoptSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
171 virtual void rejectSymKey( HCRYPTKEY aSymKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
173 virtual HCRYPTKEY getSymKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
175 virtual void adoptPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
177 virtual void rejectPubKey( HCRYPTKEY aPubKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
179 virtual HCRYPTKEY getPubKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
181 virtual void adoptPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
183 virtual void rejectPriKey( HCRYPTKEY aPriKey ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
185 virtual HCRYPTKEY getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
187 virtual void enableDefaultCrypt( sal_Bool enable ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
189 virtual sal_Bool defaultEnabled() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
191 //Native mehtods
192 virtual xmlSecKeysMngrPtr createKeysManager() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
194 virtual void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
197 #endif // _XSECURITYENVIRONMENT_MSCRYPTIMPL_HXX_