merged tag ooo/OOO330_m14
[LibreOffice.git] / xmlsecurity / source / framework / xmlsignaturetemplateimpl.cxx
blob6b50d7b017eda2f49733bfc6e01879844eca51bc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
30 #include <sal/config.h>
31 #include <rtl/ustring.hxx>
32 #include <rtl/uuid.h>
33 #include "xmlsignaturetemplateimpl.hxx"
35 using namespace ::com::sun::star::uno ;
36 using ::com::sun::star::lang::XMultiServiceFactory ;
37 using ::com::sun::star::lang::XSingleServiceFactory ;
38 using ::rtl::OUString ;
40 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
41 using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ;
43 XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
44 :m_xTemplate( NULL ),
45 m_xServiceManager( aFactory ),
46 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN )
50 XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() {
53 /* XXMLSignatureTemplate */
54 void SAL_CALL XMLSignatureTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
55 throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
57 m_xTemplate = aTemplate ;
60 /* XXMLSignatureTemplate */
61 Reference< XXMLElementWrapper > SAL_CALL XMLSignatureTemplateImpl :: getTemplate()
62 throw (com::sun::star::uno::RuntimeException)
64 return m_xTemplate ;
67 void SAL_CALL XMLSignatureTemplateImpl :: setTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement )
68 throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
70 targets.push_back( aXmlElement );
73 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl :: getTargets()
74 throw (com::sun::star::uno::RuntimeException)
76 sal_Int32 length = targets.size();
77 ::com::sun::star::uno::Sequence<
78 ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >
79 > aTargets (length);
81 sal_Int32 i;
83 for (i=0; i<length; i++)
85 aTargets[i] = targets[i];
88 return aTargets;
91 void SAL_CALL XMLSignatureTemplateImpl::setBinding(
92 const ::com::sun::star::uno::Reference<
93 ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding )
94 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
96 m_xUriBinding = aUriBinding;
99 ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > SAL_CALL XMLSignatureTemplateImpl::getBinding()
100 throw (::com::sun::star::uno::RuntimeException)
102 return m_xUriBinding;
105 void SAL_CALL XMLSignatureTemplateImpl::setStatus(
106 ::com::sun::star::xml::crypto::SecurityOperationStatus status )
107 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
109 m_nStatus = status;
112 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLSignatureTemplateImpl::getStatus( )
113 throw (::com::sun::star::uno::RuntimeException)
115 return m_nStatus;
118 /* XInitialization */
119 void SAL_CALL XMLSignatureTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) {
120 // TBD
123 /* XServiceInfo */
124 OUString SAL_CALL XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException ) {
125 return impl_getImplementationName() ;
128 /* XServiceInfo */
129 sal_Bool SAL_CALL XMLSignatureTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
130 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
131 const OUString* pArray = seqServiceNames.getConstArray() ;
132 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
133 if( *( pArray + i ) == serviceName )
134 return sal_True ;
136 return sal_False ;
139 /* XServiceInfo */
140 Sequence< OUString > SAL_CALL XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
141 return impl_getSupportedServiceNames() ;
144 //Helper for XServiceInfo
145 Sequence< OUString > XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() {
146 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
147 Sequence< OUString > seqServiceNames( 1 ) ;
148 seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLSignatureTemplate" ) ;
149 return seqServiceNames ;
152 OUString XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
153 return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLSignatureTemplateImpl" ) ;
156 //Helper for registry
157 Reference< XInterface > SAL_CALL XMLSignatureTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
158 return Reference< XInterface >( *new XMLSignatureTemplateImpl( aServiceManager ) ) ;
161 Reference< XSingleServiceFactory > XMLSignatureTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
162 //Reference< XSingleServiceFactory > xFactory ;
163 //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
164 //return xFactory ;
165 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;