27#include <xmlsec/mscng/app.h>
28#include <com/sun/star/xml/crypto/SecurityEnvironment.hpp>
29#include <com/sun/star/xml/crypto/XMLSecurityContext.hpp>
39 const uno::Reference< uno::XComponentContext > &rxContext)
49uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL
51 const OUString& sCertDB )
53 const char* n_pCertStore ;
54 HCERTSTORE n_hStoreHandle ;
58 if( sCertDB.getLength() > 0 )
61 n_pCertStore = sCertDir.getStr();
62 n_hStoreHandle = CertOpenSystemStoreW( 0, o3tl::toW(sCertDB.getStr())) ;
63 if( n_hStoreHandle ==
nullptr )
70 n_pCertStore = nullptr ;
71 n_hStoreHandle = nullptr ;
74 xmlSecMSCngAppInit(n_pCertStore);
78 uno::Reference< cssxc::XSecurityEnvironment > xSecEnv = cssxc::SecurityEnvironment::create(
mxContext );
82 if( pSecEnv ==
nullptr )
84 if( n_hStoreHandle !=
nullptr )
86 CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
89 xmlSecMSCngAppShutdown();
93 if( n_hStoreHandle !=
nullptr )
104 uno::Reference< cssxc::XXMLSecurityContext > xSecCtx = cssxc::XMLSecurityContext::create(
mxContext );
106 xSecCtx->setDefaultSecurityEnvironmentIndex(xSecCtx->addSecurityEnvironment( xSecEnv )) ;
109 catch( uno::Exception& )
111 if( n_hStoreHandle !=
nullptr )
113 CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
116 xmlSecMSCngAppShutdown();
146 xmlSecMSCngAppShutdown();
152 return "com.sun.star.xml.crypto.SEInitializer";
162 return {
"com.sun.star.xml.crypto.SEInitializer" };
165extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
167 uno::XComponentContext* pCtx, uno::Sequence<uno::Any>
const& )
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL freeSecurityContext(const css::uno::Reference< css::xml::crypto::XXMLSecurityContext > &securityContext) override
virtual css::uno::Reference< css::xml::crypto::XXMLSecurityContext > SAL_CALL createSecurityContext(const OUString &certDB) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
SEInitializer_MSCryptImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual ~SEInitializer_MSCryptImpl() override
void setCertDb(HCERTSTORE aCertDb)
void setCryptoSlot(HCERTSTORE aKeyStore)
void enableDefaultCrypt(bool enable)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_xml_crypto_SEInitializer_get_implementation(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)