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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmlsecurity.hxx" 30 #include <sal/config.h> 31 #include <rtl/uuid.h> 32 #include "xmlencryptiontemplateimpl.hxx" 33 34 using namespace ::com::sun::star::uno ; 35 using ::com::sun::star::lang::XMultiServiceFactory ; 36 using ::com::sun::star::lang::XSingleServiceFactory ; 37 using ::rtl::OUString ; 38 39 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; 40 using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ; 41 42 XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory ) 43 : m_xTemplate( NULL ), 44 m_xTarget( NULL ), 45 m_xServiceManager( aFactory ), 46 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) { 47 } 48 49 XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() { 50 } 51 52 /* XXMLEncryptionTemplate */ 53 void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate ) 54 throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) 55 { 56 m_xTemplate = aTemplate ; 57 } 58 59 /* XXMLEncryptionTemplate */ 60 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate() 61 throw (com::sun::star::uno::RuntimeException) 62 { 63 return m_xTemplate ; 64 } 65 66 /* XXMLEncryptionTemplate */ 67 void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget ) 68 throw( com::sun::star::lang::IllegalArgumentException ) { 69 m_xTarget = aTarget ; 70 } 71 72 /* XXMLEncryptionTemplate */ 73 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget() 74 throw (com::sun::star::uno::RuntimeException) 75 { 76 return m_xTarget ; 77 } 78 79 void SAL_CALL XMLEncryptionTemplateImpl::setStatus( 80 ::com::sun::star::xml::crypto::SecurityOperationStatus status ) 81 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 82 { 83 m_nStatus = status; 84 } 85 86 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( ) 87 throw (::com::sun::star::uno::RuntimeException) 88 { 89 return m_nStatus; 90 } 91 92 /* XInitialization */ 93 void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) 94 throw( Exception, RuntimeException ) { 95 // TBD 96 } ; 97 98 /* XServiceInfo */ 99 OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) { 100 return impl_getImplementationName() ; 101 } 102 103 /* XServiceInfo */ 104 sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { 105 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; 106 const OUString* pArray = seqServiceNames.getConstArray() ; 107 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { 108 if( *( pArray + i ) == serviceName ) 109 return sal_True ; 110 } 111 return sal_False ; 112 } 113 114 /* XServiceInfo */ 115 Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) { 116 return impl_getSupportedServiceNames() ; 117 } 118 119 //Helper for XServiceInfo 120 Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() { 121 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; 122 Sequence< OUString > seqServiceNames( 1 ) ; 123 seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryptionTemplate" ) ; 124 return seqServiceNames ; 125 } 126 127 OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) { 128 return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl" ) ; 129 } 130 131 //Helper for registry 132 Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { 133 return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ; 134 } 135 136 Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { 137 //Reference< XSingleServiceFactory > xFactory ; 138 //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; 139 //return xFactory ; 140 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; 141 } 142 143