Bump version to 5.0-14
[LibreOffice.git] / xmlsecurity / source / xmlsec / mscrypt / securityenvironment_mscryptimpl.hxx
blob793f70972271cb91afd1f6398bfb6a4e3e44c711
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_SECURITYENVIRONMENT_MSCRYPTIMPL_HXX
21 #define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_SECURITYENVIRONMENT_MSCRYPTIMPL_HXX
23 #ifdef _MSC_VER
24 #pragma warning(push,1)
25 #endif
26 #include <windows.h>
27 #include <wincrypt.h>
28 #ifdef _MSC_VER
29 #pragma warning(pop)
30 #endif
31 #include <sal/config.h>
32 #include <rtl/ustring.hxx>
33 #include <cppuhelper/factory.hxx>
34 #include <cppuhelper/implbase3.hxx>
35 #include <com/sun/star/uno/Exception.hpp>
37 #include <com/sun/star/uno/Reference.hxx>
38 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
42 #include <com/sun/star/security/XCertificate.hpp>
43 #include <com/sun/star/security/CertificateCharacters.hpp>
44 #include <com/sun/star/security/CertificateValidity.hpp>
45 #include <com/sun/star/lang/XUnoTunnel.hpp>
47 #include <list>
48 #include "xmlsecurity/xmlsec-wrapper.h"
50 #include <sal/types.h>
53 class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper3<
54 ::com::sun::star::xml::crypto::XSecurityEnvironment ,
55 ::com::sun::star::lang::XServiceInfo,
56 ::com::sun::star::lang::XUnoTunnel >
58 private :
59 //cyrpto provider and key container
60 HCRYPTPROV m_hProv ;
61 LPCTSTR m_pszContainer ;
63 //Key store
64 HCERTSTORE m_hKeyStore ;
66 //Certiticate store
67 HCERTSTORE m_hCertStore ;
69 // i120675, save the store handles
70 HCERTSTORE m_hMySystemStore;
71 HCERTSTORE m_hRootSystemStore;
72 HCERTSTORE m_hTrustSystemStore;
73 HCERTSTORE m_hCaSystemStore;
75 //Enable default system cryptography setting
76 sal_Bool m_bEnableDefault ;
78 //External keys
79 std::list< HCRYPTKEY > m_tSymKeyList ;
80 std::list< HCRYPTKEY > m_tPubKeyList ;
81 std::list< HCRYPTKEY > m_tPriKeyList ;
83 //Service manager
84 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager ;
86 public :
87 SecurityEnvironment_MSCryptImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aFactory ) ;
88 virtual ~SecurityEnvironment_MSCryptImpl() ;
90 //Methods from XSecurityEnvironment
91 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL getPersonalCertificates()
92 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
94 virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate(
95 const OUString& issuerName,
96 const ::com::sun::star::uno::Sequence< sal_Int8 >& serialNumber )
97 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL getCertificate(
100 const OUString& issuerName,
101 const OUString& serialNumber )
102 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
104 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > > SAL_CALL buildCertificatePath(
105 const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& beginCert )
106 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
108 virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromRaw(
109 const ::com::sun::star::uno::Sequence< sal_Int8 >& rawCertificate )
110 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
112 virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL createCertificateFromAscii(
113 const OUString& asciiCertificate )
114 throw( ::com::sun::star::uno::SecurityException , ::com::sun::star::uno::RuntimeException ) ;
116 virtual ::sal_Int32 SAL_CALL verifyCertificate(
117 const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& xCert,
118 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
119 ::com::sun::star::security::XCertificate > >& intermediateCertificates)
120 throw (::com::sun::star::uno::SecurityException, ::com::sun::star::uno::RuntimeException) ;
122 virtual ::sal_Int32 SAL_CALL getCertificateCharacters(
123 const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& xCert )
124 throw (::com::sun::star::uno::SecurityException, ::com::sun::star::uno::RuntimeException) ;
126 virtual OUString SAL_CALL getSecurityEnvironmentInformation( )
127 throw (::com::sun::star::uno::RuntimeException);
130 //Methods from XServiceInfo
131 virtual OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
133 virtual sal_Bool SAL_CALL supportsService(
134 const OUString& ServiceName
135 ) throw( ::com::sun::star::uno::RuntimeException ) ;
137 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) ;
139 //Helper for XServiceInfo
140 static ::com::sun::star::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
142 static OUString impl_getImplementationName() throw( ::com::sun::star::uno::RuntimeException ) ;
144 //Helper for registry
145 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_createInstance(
146 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager )
147 throw( ::com::sun::star::uno::RuntimeException ) ;
149 static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > impl_createFactory(
150 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager ) ;
152 //Methods from XUnoTunnel
153 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
154 throw (::com::sun::star::uno::RuntimeException);
156 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
157 static SecurityEnvironment_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rObj ) ;
159 //Native methods
160 virtual HCRYPTPROV getCryptoProvider() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
161 virtual void setCryptoProvider( HCRYPTPROV aProv ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
163 virtual LPCTSTR getKeyContainer() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
164 virtual void setKeyContainer( LPCTSTR aKeyContainer ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
166 virtual HCERTSTORE getCryptoSlot() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
167 virtual void setCryptoSlot( HCERTSTORE aKeyStore ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
169 virtual HCERTSTORE getCertDb() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
170 virtual void setCertDb( HCERTSTORE aCertDb ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
172 virtual void adoptSymKey( 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 HCRYPTKEY getPubKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
177 virtual HCRYPTKEY getPriKey( unsigned int position ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
179 virtual void enableDefaultCrypt( sal_Bool enable ) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
180 virtual sal_Bool defaultEnabled() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
182 //Native methods
183 virtual xmlSecKeysMngrPtr createKeysManager() throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
185 virtual void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr) throw( ::com::sun::star::uno::Exception , ::com::sun::star::uno::RuntimeException ) ;
188 #endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_SECURITYENVIRONMENT_MSCRYPTIMPL_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */