merged tag ooo/OOO330_m14
[LibreOffice.git] / xmlsecurity / source / framework / xmlencryptiontemplateimpl.cxx
blobec978dc488e11a05a00cb594eb6cee8156baab10
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/uuid.h>
32 #include "xmlencryptiontemplateimpl.hxx"
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 ;
39 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
40 using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
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 ) {
49 XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
52 /* XXMLEncryptionTemplate */
53 void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
54 throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
56 m_xTemplate = aTemplate ;
59 /* XXMLEncryptionTemplate */
60 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
61 throw (com::sun::star::uno::RuntimeException)
63 return m_xTemplate ;
66 /* XXMLEncryptionTemplate */
67 void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
68 throw( com::sun::star::lang::IllegalArgumentException ) {
69 m_xTarget = aTarget ;
72 /* XXMLEncryptionTemplate */
73 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
74 throw (com::sun::star::uno::RuntimeException)
76 return m_xTarget ;
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)
83 m_nStatus = status;
86 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( )
87 throw (::com::sun::star::uno::RuntimeException)
89 return m_nStatus;
92 /* XInitialization */
93 void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ )
94 throw( Exception, RuntimeException ) {
95 // TBD
96 } ;
98 /* XServiceInfo */
99 OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) {
100 return impl_getImplementationName() ;
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 ;
111 return sal_False ;
114 /* XServiceInfo */
115 Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
116 return impl_getSupportedServiceNames() ;
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 ;
127 OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
128 return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl" ) ;
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 ) ) ;
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() ) ;