LibreOffice Module xmlsecurity (master) 1
securityenvironment_mscryptimpl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#if !defined WIN32_LEAN_AND_MEAN
23# define WIN32_LEAN_AND_MEAN
24#endif
25#include <windows.h>
26#include <wincrypt.h>
27#include <sal/config.h>
28#include <rtl/ustring.hxx>
32#include <com/sun/star/uno/Exception.hpp>
33
34#include <com/sun/star/uno/Reference.hxx>
35#include <com/sun/star/lang/XSingleServiceFactory.hpp>
36
37#include <com/sun/star/lang/XServiceInfo.hpp>
38#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
39#include <com/sun/star/security/XCertificate.hpp>
40#include <com/sun/star/security/CertificateCharacters.hpp>
41#include <com/sun/star/security/CertificateValidity.hpp>
42
43#include <vector>
44#include <xmlsec-wrapper.h>
45
46#include <sal/types.h>
47
48
49class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper<
50 css::xml::crypto::XSecurityEnvironment ,
51 css::lang::XServiceInfo >
52{
53 private:
54 //crypto provider and key container
55 HCRYPTPROV m_hProv ;
57
58 //Key store
59 HCERTSTORE m_hKeyStore ;
60
61 //Certificate store
62 HCERTSTORE m_hCertStore ;
63
64 // i120675, save the store handles
65 HCERTSTORE m_hMySystemStore;
68 HCERTSTORE m_hCaSystemStore;
69
70 //Enable default system cryptography setting
72
73 //Service manager
74 css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager ;
75
76 public:
77 explicit SecurityEnvironment_MSCryptImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) ;
78 virtual ~SecurityEnvironment_MSCryptImpl() override;
79
80 //Methods from XSecurityEnvironment
81 virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates() override;
82 virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getAllCertificates() override
83 { return css::uno::Sequence< css::uno::Reference< css::security::XCertificate > >(); }
84
85 virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate(
86 const OUString& issuerName,
87 const css::uno::Sequence< sal_Int8 >& serialNumber ) override;
88
91 virtual css::uno::Reference< css::security::XCertificate > getCertificate(
92 const OUString& issuerName,
93 const OUString& serialNumber ) ;
94
95 virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL buildCertificatePath(
96 const css::uno::Reference< css::security::XCertificate >& beginCert ) override;
97
98 virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromRaw(
99 const css::uno::Sequence< sal_Int8 >& rawCertificate ) override;
100
101 virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromAscii(
102 const OUString& asciiCertificate ) override;
103
104 virtual ::sal_Int32 SAL_CALL verifyCertificate(
105 const css::uno::Reference< css::security::XCertificate >& xCert,
106 const css::uno::Sequence< css::uno::Reference<
107 css::security::XCertificate > >& intermediateCertificates) override;
108
109 virtual ::sal_Int32 SAL_CALL getCertificateCharacters(
110 const css::uno::Reference< css::security::XCertificate >& xCert ) override;
111
112 virtual OUString SAL_CALL getSecurityEnvironmentInformation( ) override;
113
114
115 //Methods from XServiceInfo
116 virtual OUString SAL_CALL getImplementationName() override;
117
118 virtual sal_Bool SAL_CALL supportsService(
119 const OUString& ServiceName
120 ) override;
121
122 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
123
126 HCRYPTPROV getCryptoProvider() ;
129 void setCryptoProvider( HCRYPTPROV aProv ) ;
130
133 LPCTSTR getKeyContainer() ;
136 void setKeyContainer( LPCTSTR aKeyContainer ) ;
137
140 HCERTSTORE getCryptoSlot() ;
143 void setCryptoSlot( HCERTSTORE aKeyStore ) ;
144
147 HCERTSTORE getCertDb() ;
150 void setCertDb( HCERTSTORE aCertDb ) ;
151
154 void enableDefaultCrypt( bool enable ) ;
157 bool defaultEnabled() ;
158
161 xmlSecKeysMngrPtr createKeysManager() ;
162
165 static void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr) ;
166} ;
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SecurityEnvironment_MSCryptImpl(const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getSecurityEnvironmentInformation() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static void destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr)
virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates() override
virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromRaw(const css::uno::Sequence< sal_Int8 > &rawCertificate) override
virtual ::sal_Int32 SAL_CALL verifyCertificate(const css::uno::Reference< css::security::XCertificate > &xCert, const css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > &intermediateCertificates) override
virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromAscii(const OUString &asciiCertificate) override
virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL buildCertificatePath(const css::uno::Reference< css::security::XCertificate > &beginCert) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getAllCertificates() override
virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate(const OUString &issuerName, const css::uno::Sequence< sal_Int8 > &serialNumber) override
virtual ::sal_Int32 SAL_CALL getCertificateCharacters(const css::uno::Reference< css::security::XCertificate > &xCert) override
css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager
unsigned char sal_Bool