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
10*06b3ce53SAndrew Rist  *
11*06b3ce53SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06b3ce53SAndrew Rist  *
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.
19*06b3ce53SAndrew Rist  *
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/uuid.h>
28cdf0e10cSrcweir #include "xmlencryptiontemplateimpl.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
31cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory ;
32cdf0e10cSrcweir using ::com::sun::star::lang::XSingleServiceFactory ;
33cdf0e10cSrcweir using ::rtl::OUString ;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
36cdf0e10cSrcweir using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
37cdf0e10cSrcweir 
XMLEncryptionTemplateImpl(const Reference<XMultiServiceFactory> & aFactory)38cdf0e10cSrcweir XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
39cdf0e10cSrcweir 	: m_xTemplate( NULL ),
40cdf0e10cSrcweir       m_xTarget( NULL ),
41cdf0e10cSrcweir       m_xServiceManager( aFactory ),
42cdf0e10cSrcweir 	  m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) {
43cdf0e10cSrcweir }
44cdf0e10cSrcweir 
~XMLEncryptionTemplateImpl()45cdf0e10cSrcweir XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /* XXMLEncryptionTemplate */
setTemplate(const Reference<XXMLElementWrapper> & aTemplate)49cdf0e10cSrcweir void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
50cdf0e10cSrcweir 	throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	m_xTemplate = aTemplate ;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /* XXMLEncryptionTemplate */
getTemplate()56cdf0e10cSrcweir Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
57cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	return m_xTemplate ;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir /* XXMLEncryptionTemplate */
setTarget(const Reference<XXMLElementWrapper> & aTarget)63cdf0e10cSrcweir void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
64cdf0e10cSrcweir 	throw( com::sun::star::lang::IllegalArgumentException ) {
65cdf0e10cSrcweir 	m_xTarget = aTarget ;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /* XXMLEncryptionTemplate */
getTarget()69cdf0e10cSrcweir Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
70cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	return m_xTarget ;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
setStatus(::com::sun::star::xml::crypto::SecurityOperationStatus status)75cdf0e10cSrcweir void SAL_CALL XMLEncryptionTemplateImpl::setStatus(
76cdf0e10cSrcweir 	::com::sun::star::xml::crypto::SecurityOperationStatus status )
77cdf0e10cSrcweir 	throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	m_nStatus = status;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
getStatus()82cdf0e10cSrcweir ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus(  )
83cdf0e10cSrcweir 	throw (::com::sun::star::uno::RuntimeException)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	return m_nStatus;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir /* XInitialization */
initialize(const Sequence<Any> &)89cdf0e10cSrcweir void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ )
90cdf0e10cSrcweir     throw( Exception, RuntimeException ) {
91cdf0e10cSrcweir 	// TBD
92cdf0e10cSrcweir } ;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir /* XServiceInfo */
getImplementationName()95cdf0e10cSrcweir OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) {
96cdf0e10cSrcweir 	return impl_getImplementationName() ;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir /* XServiceInfo */
supportsService(const OUString & serviceName)100cdf0e10cSrcweir sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
101cdf0e10cSrcweir 	Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
102cdf0e10cSrcweir 	const OUString* pArray = seqServiceNames.getConstArray() ;
103cdf0e10cSrcweir 	for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
104cdf0e10cSrcweir 		if( *( pArray + i ) == serviceName )
105cdf0e10cSrcweir 			return sal_True ;
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 	return sal_False ;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /* XServiceInfo */
getSupportedServiceNames()111cdf0e10cSrcweir Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
112cdf0e10cSrcweir 	return impl_getSupportedServiceNames() ;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //Helper for XServiceInfo
impl_getSupportedServiceNames()116cdf0e10cSrcweir Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() {
117cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
118cdf0e10cSrcweir 	Sequence< OUString > seqServiceNames( 1 ) ;
119cdf0e10cSrcweir 	seqServiceNames.getArray()[0] = OUString::createFromAscii( "com.sun.star.xml.crypto.XMLEncryptionTemplate" ) ;
120cdf0e10cSrcweir 	return seqServiceNames ;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
impl_getImplementationName()123cdf0e10cSrcweir OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
124cdf0e10cSrcweir 	return OUString::createFromAscii( "com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl" ) ;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir //Helper for registry
impl_createInstance(const Reference<XMultiServiceFactory> & aServiceManager)128cdf0e10cSrcweir Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
129cdf0e10cSrcweir 	return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
impl_createFactory(const Reference<XMultiServiceFactory> & aServiceManager)132cdf0e10cSrcweir Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
133cdf0e10cSrcweir 	//Reference< XSingleServiceFactory > xFactory ;
134cdf0e10cSrcweir 	//xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
135cdf0e10cSrcweir 	//return xFactory ;
136cdf0e10cSrcweir 	return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139