1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef _ENCRYPTORIMPL_HXX 29 #define _ENCRYPTORIMPL_HXX 30 31 #include <com/sun/star/xml/crypto/sax/XEncryptionResultBroadcaster.hpp> 32 #include <com/sun/star/xml/crypto/sax/XEncryptionResultListener.hpp> 33 #ifndef _COM_SUN_STAR_XML_CRYPTO_SAX_XSIGNATURECOLLECTOR_HPP_ 34 #include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp> 35 #endif 36 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> 37 #include <com/sun/star/lang/XInitialization.hpp> 38 #include <com/sun/star/lang/XServiceInfo.hpp> 39 #include <cppuhelper/implbase4.hxx> 40 41 #include "encryptionengine.hxx" 42 43 class EncryptorImpl : public cppu::ImplInheritanceHelper4 44 < 45 EncryptionEngine, 46 com::sun::star::xml::crypto::sax::XEncryptionResultBroadcaster, 47 com::sun::star::xml::crypto::sax::XReferenceCollector, 48 com::sun::star::lang::XInitialization, 49 com::sun::star::lang::XServiceInfo 50 > 51 /****** EncryptorImpl.hxx/CLASS EncryptorImpl ********************************* 52 * 53 * NAME 54 * EncryptorImpl -- generates an encryption 55 * 56 * FUNCTION 57 * Collects all resources for an encryption generation, then generates the 58 * encryption by invoking a xmlsec-based encryption bridge component. 59 * 60 * HISTORY 61 * 05.01.2004 - Interface supported: XInitialization, XServiceInfo 62 * 63 * AUTHOR 64 * Michael Mi 65 * Email: michael.mi@sun.com 66 ******************************************************************************/ 67 { 68 private: 69 /* 70 * the Id of the encryption, which is used for the result listener to 71 * identify the encryption. 72 */ 73 sal_Int32 m_nEncryptionId; 74 75 /* 76 * the Id of the element to be encrypted. 77 */ 78 sal_Int32 m_nReferenceId; 79 80 /* 81 * the decryption result, 82 * remembers whether the encryption succeeds. 83 */ 84 bool m_bEncryptionSucceed; 85 86 com::sun::star::uno::Reference< 87 com::sun::star::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment; 88 89 virtual void notifyResultListener() const 90 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 91 virtual bool checkReady() const; 92 virtual void startEngine( const com::sun::star::uno::Reference< 93 com::sun::star::xml::crypto::XXMLEncryptionTemplate >& 94 xEncryptionTemplate) 95 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 96 97 public: 98 explicit EncryptorImpl( const com::sun::star::uno::Reference< 99 com::sun::star::lang::XMultiServiceFactory >& rxMSF); 100 virtual ~EncryptorImpl(); 101 102 /* XEncryptionResultBroadcaster */ 103 virtual void SAL_CALL addEncryptionResultListener( 104 const com::sun::star::uno::Reference< 105 com::sun::star::xml::crypto::sax::XEncryptionResultListener >& 106 listener ) 107 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 108 virtual void SAL_CALL removeEncryptionResultListener( 109 const com::sun::star::uno::Reference< 110 com::sun::star::xml::crypto::sax::XEncryptionResultListener >& 111 listener ) 112 throw (com::sun::star::uno::RuntimeException); 113 114 /* XReferenceCollector */ 115 virtual void SAL_CALL setReferenceCount( sal_Int32 count ) 116 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 117 118 virtual void SAL_CALL setReferenceId( sal_Int32 id ) 119 throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); 120 121 /* 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); 125 126 /* XServiceInfo */ 127 virtual rtl::OUString SAL_CALL getImplementationName( ) 128 throw (com::sun::star::uno::RuntimeException); 129 virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) 130 throw (com::sun::star::uno::RuntimeException); 131 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames( ) 132 throw (com::sun::star::uno::RuntimeException); 133 }; 134 135 rtl::OUString EncryptorImpl_getImplementationName() 136 throw ( com::sun::star::uno::RuntimeException ); 137 138 sal_Bool SAL_CALL EncryptorImpl_supportsService( const rtl::OUString& ServiceName ) 139 throw ( com::sun::star::uno::RuntimeException ); 140 141 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( ) 142 throw ( com::sun::star::uno::RuntimeException ); 143 144 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 145 SAL_CALL EncryptorImpl_createInstance( 146 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr) 147 throw ( com::sun::star::uno::Exception ); 148 149 #endif 150 151