Update ooo320-m1
[ooovba.git] / xmlsecurity / source / framework / xmlencryptiontemplateimpl.cxx
blob3f0c46c8561618a894f2919e62da29512fda3f51
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: xmlencryptiontemplateimpl.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/uuid.h>
35 #include "xmlencryptiontemplateimpl.hxx"
37 using namespace ::com::sun::star::uno ;
38 using ::com::sun::star::lang::XMultiServiceFactory ;
39 using ::com::sun::star::lang::XSingleServiceFactory ;
40 using ::rtl::OUString ;
42 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
43 using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
45 XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
46 : m_xTemplate( NULL ),
47 m_xTarget( NULL ),
48 m_xServiceManager( aFactory ),
49 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) {
52 XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
55 /* XXMLEncryptionTemplate */
56 void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
57 throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
59 m_xTemplate = aTemplate ;
62 /* XXMLEncryptionTemplate */
63 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
64 throw (com::sun::star::uno::RuntimeException)
66 return m_xTemplate ;
69 /* XXMLEncryptionTemplate */
70 void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
71 throw( com::sun::star::lang::IllegalArgumentException ) {
72 m_xTarget = aTarget ;
75 /* XXMLEncryptionTemplate */
76 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
77 throw (com::sun::star::uno::RuntimeException)
79 return m_xTarget ;
82 void SAL_CALL XMLEncryptionTemplateImpl::setStatus(
83 ::com::sun::star::xml::crypto::SecurityOperationStatus status )
84 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
86 m_nStatus = status;
89 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( )
90 throw (::com::sun::star::uno::RuntimeException)
92 return m_nStatus;
95 /* XInitialization */
96 void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ )
97 throw( Exception, RuntimeException ) {
98 // TBD
99 } ;
101 /* XServiceInfo */
102 OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) {
103 return impl_getImplementationName() ;
106 /* XServiceInfo */
107 sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
108 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
109 const OUString* pArray = seqServiceNames.getConstArray() ;
110 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
111 if( *( pArray + i ) == serviceName )
112 return sal_True ;
114 return sal_False ;
117 /* XServiceInfo */
118 Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
119 return impl_getSupportedServiceNames() ;
122 //Helper for XServiceInfo
123 Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() {
124 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
125 Sequence< OUString > seqServiceNames( 1 ) ;
126 seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryptionTemplate" ) ;
127 return seqServiceNames ;
130 OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
131 return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl" ) ;
134 //Helper for registry
135 Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
136 return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ;
139 Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
140 //Reference< XSingleServiceFactory > xFactory ;
141 //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
142 //return xFactory ;
143 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;