Update ooo320-m1
[ooovba.git] / xmlsecurity / source / framework / xmlsignaturetemplateimpl.cxx
blob830e35990f12d306e9f38cf9fa3e33af4e895162
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlsignaturetemplateimpl.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
33 #include <sal/config.h>
34 #include <rtl/ustring.hxx>
35 #include <rtl/uuid.h>
36 #include "xmlsignaturetemplateimpl.hxx"
38 using namespace ::com::sun::star::uno ;
39 using ::com::sun::star::lang::XMultiServiceFactory ;
40 using ::com::sun::star::lang::XSingleServiceFactory ;
41 using ::rtl::OUString ;
43 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
44 using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ;
46 XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
47 :m_xTemplate( NULL ),
48 m_xServiceManager( aFactory ),
49 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN )
53 XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() {
56 /* XXMLSignatureTemplate */
57 void SAL_CALL XMLSignatureTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
58 throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
60 m_xTemplate = aTemplate ;
63 /* XXMLSignatureTemplate */
64 Reference< XXMLElementWrapper > SAL_CALL XMLSignatureTemplateImpl :: getTemplate()
65 throw (com::sun::star::uno::RuntimeException)
67 return m_xTemplate ;
70 void SAL_CALL XMLSignatureTemplateImpl :: setTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement )
71 throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
73 targets.push_back( aXmlElement );
76 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl :: getTargets()
77 throw (com::sun::star::uno::RuntimeException)
79 sal_Int32 length = targets.size();
80 ::com::sun::star::uno::Sequence<
81 ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >
82 > aTargets (length);
84 sal_Int32 i;
86 for (i=0; i<length; i++)
88 aTargets[i] = targets[i];
91 return aTargets;
94 void SAL_CALL XMLSignatureTemplateImpl::setBinding(
95 const ::com::sun::star::uno::Reference<
96 ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding )
97 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
99 m_xUriBinding = aUriBinding;
102 ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > SAL_CALL XMLSignatureTemplateImpl::getBinding()
103 throw (::com::sun::star::uno::RuntimeException)
105 return m_xUriBinding;
108 void SAL_CALL XMLSignatureTemplateImpl::setStatus(
109 ::com::sun::star::xml::crypto::SecurityOperationStatus status )
110 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
112 m_nStatus = status;
115 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLSignatureTemplateImpl::getStatus( )
116 throw (::com::sun::star::uno::RuntimeException)
118 return m_nStatus;
121 /* XInitialization */
122 void SAL_CALL XMLSignatureTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) {
123 // TBD
126 /* XServiceInfo */
127 OUString SAL_CALL XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException ) {
128 return impl_getImplementationName() ;
131 /* XServiceInfo */
132 sal_Bool SAL_CALL XMLSignatureTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
133 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
134 const OUString* pArray = seqServiceNames.getConstArray() ;
135 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
136 if( *( pArray + i ) == serviceName )
137 return sal_True ;
139 return sal_False ;
142 /* XServiceInfo */
143 Sequence< OUString > SAL_CALL XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
144 return impl_getSupportedServiceNames() ;
147 //Helper for XServiceInfo
148 Sequence< OUString > XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() {
149 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
150 Sequence< OUString > seqServiceNames( 1 ) ;
151 seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignatureTemplate" ) ;
152 return seqServiceNames ;
155 OUString XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
156 return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLSignatureTemplateImpl" ) ;
159 //Helper for registry
160 Reference< XInterface > SAL_CALL XMLSignatureTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
161 return Reference< XInterface >( *new XMLSignatureTemplateImpl( aServiceManager ) ) ;
164 Reference< XSingleServiceFactory > XMLSignatureTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
165 //Reference< XSingleServiceFactory > xFactory ;
166 //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
167 //return xFactory ;
168 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;