1*06b3ce53SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06b3ce53SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06b3ce53SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06b3ce53SAndrew Rist * distributed with this work for additional information 6*06b3ce53SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06b3ce53SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06b3ce53SAndrew Rist * "License"); you may not use this file except in compliance 9*06b3ce53SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*06b3ce53SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*06b3ce53SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06b3ce53SAndrew Rist * software distributed under the License is distributed on an 15*06b3ce53SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06b3ce53SAndrew Rist * KIND, either express or implied. See the License for the 17*06b3ce53SAndrew Rist * specific language governing permissions and limitations 18*06b3ce53SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*06b3ce53SAndrew Rist *************************************************************/ 21*06b3ce53SAndrew Rist 22*06b3ce53SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx" 26cdf0e10cSrcweir #include <sal/config.h> 27cdf0e10cSrcweir #include <rtl/ustring.hxx> 28cdf0e10cSrcweir #include <rtl/uuid.h> 29cdf0e10cSrcweir #include "xmlsignaturetemplateimpl.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 32cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory ; 33cdf0e10cSrcweir using ::com::sun::star::lang::XSingleServiceFactory ; 34cdf0e10cSrcweir using ::rtl::OUString ; 35cdf0e10cSrcweir 36cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLElementWrapper ; 37cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; 38cdf0e10cSrcweir 39cdf0e10cSrcweir XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference< XMultiServiceFactory >& aFactory ) 40cdf0e10cSrcweir :m_xTemplate( NULL ), 41cdf0e10cSrcweir m_xServiceManager( aFactory ), 42cdf0e10cSrcweir m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() { 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir /* XXMLSignatureTemplate */ 50cdf0e10cSrcweir void SAL_CALL XMLSignatureTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate ) 51cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir m_xTemplate = aTemplate ; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir /* XXMLSignatureTemplate */ 57cdf0e10cSrcweir Reference< XXMLElementWrapper > SAL_CALL XMLSignatureTemplateImpl :: getTemplate() 58cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir return m_xTemplate ; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir void SAL_CALL XMLSignatureTemplateImpl :: setTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement ) 64cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir targets.push_back( aXmlElement ); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl :: getTargets() 70cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir sal_Int32 length = targets.size(); 73cdf0e10cSrcweir ::com::sun::star::uno::Sequence< 74cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > 75cdf0e10cSrcweir > aTargets (length); 76cdf0e10cSrcweir 77cdf0e10cSrcweir sal_Int32 i; 78cdf0e10cSrcweir 79cdf0e10cSrcweir for (i=0; i<length; i++) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir aTargets[i] = targets[i]; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir return aTargets; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir void SAL_CALL XMLSignatureTemplateImpl::setBinding( 88cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 89cdf0e10cSrcweir ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding ) 90cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir m_xUriBinding = aUriBinding; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > SAL_CALL XMLSignatureTemplateImpl::getBinding() 96cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir return m_xUriBinding; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir void SAL_CALL XMLSignatureTemplateImpl::setStatus( 102cdf0e10cSrcweir ::com::sun::star::xml::crypto::SecurityOperationStatus status ) 103cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir m_nStatus = status; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLSignatureTemplateImpl::getStatus( ) 109cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir return m_nStatus; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir /* XInitialization */ 115cdf0e10cSrcweir void SAL_CALL XMLSignatureTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) { 116cdf0e10cSrcweir // TBD 117cdf0e10cSrcweir } ; 118cdf0e10cSrcweir 119cdf0e10cSrcweir /* XServiceInfo */ 120cdf0e10cSrcweir OUString SAL_CALL XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException ) { 121cdf0e10cSrcweir return impl_getImplementationName() ; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir /* XServiceInfo */ 125cdf0e10cSrcweir sal_Bool SAL_CALL XMLSignatureTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) { 126cdf0e10cSrcweir Sequence< OUString > seqServiceNames = getSupportedServiceNames() ; 127cdf0e10cSrcweir const OUString* pArray = seqServiceNames.getConstArray() ; 128cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { 129cdf0e10cSrcweir if( *( pArray + i ) == serviceName ) 130cdf0e10cSrcweir return sal_True ; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir return sal_False ; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir /* XServiceInfo */ 136cdf0e10cSrcweir Sequence< OUString > SAL_CALL XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) { 137cdf0e10cSrcweir return impl_getSupportedServiceNames() ; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir //Helper for XServiceInfo 141cdf0e10cSrcweir Sequence< OUString > XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() { 142cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; 143cdf0e10cSrcweir Sequence< OUString > seqServiceNames( 1 ) ; 144cdf0e10cSrcweir seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignatureTemplate" ) ; 145cdf0e10cSrcweir return seqServiceNames ; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir OUString XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) { 149cdf0e10cSrcweir return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLSignatureTemplateImpl" ) ; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir //Helper for registry 153cdf0e10cSrcweir Reference< XInterface > SAL_CALL XMLSignatureTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) { 154cdf0e10cSrcweir return Reference< XInterface >( *new XMLSignatureTemplateImpl( aServiceManager ) ) ; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir Reference< XSingleServiceFactory > XMLSignatureTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { 158cdf0e10cSrcweir //Reference< XSingleServiceFactory > xFactory ; 159cdf0e10cSrcweir //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ; 160cdf0e10cSrcweir //return xFactory ; 161cdf0e10cSrcweir return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164