Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <sal/config.h>
21 : : #include <rtl/uuid.h>
22 : : #include "xmlencryptiontemplateimpl.hxx"
23 : :
24 : : using namespace ::com::sun::star::uno ;
25 : : using ::com::sun::star::lang::XMultiServiceFactory ;
26 : : using ::com::sun::star::lang::XSingleServiceFactory ;
27 : : using ::rtl::OUString ;
28 : :
29 : : using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
30 : : using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
31 : :
32 : 0 : XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
33 : : : m_xTemplate( NULL ),
34 : : m_xTarget( NULL ),
35 : : m_xServiceManager( aFactory ),
36 : 0 : m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) {
37 : 0 : }
38 : :
39 : 0 : XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
40 : 0 : }
41 : :
42 : : /* XXMLEncryptionTemplate */
43 : 0 : void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
44 : : throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
45 : : {
46 : 0 : m_xTemplate = aTemplate ;
47 : 0 : }
48 : :
49 : : /* XXMLEncryptionTemplate */
50 : 0 : Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
51 : : throw (com::sun::star::uno::RuntimeException)
52 : : {
53 : 0 : return m_xTemplate ;
54 : : }
55 : :
56 : : /* XXMLEncryptionTemplate */
57 : 0 : void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
58 : : throw( com::sun::star::lang::IllegalArgumentException ) {
59 : 0 : m_xTarget = aTarget ;
60 : 0 : }
61 : :
62 : : /* XXMLEncryptionTemplate */
63 : 0 : Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
64 : : throw (com::sun::star::uno::RuntimeException)
65 : : {
66 : 0 : return m_xTarget ;
67 : : }
68 : :
69 : 0 : void SAL_CALL XMLEncryptionTemplateImpl::setStatus(
70 : : ::com::sun::star::xml::crypto::SecurityOperationStatus status )
71 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
72 : : {
73 : 0 : m_nStatus = status;
74 : 0 : }
75 : :
76 : 0 : ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( )
77 : : throw (::com::sun::star::uno::RuntimeException)
78 : : {
79 : 0 : return m_nStatus;
80 : : }
81 : :
82 : : /* XInitialization */
83 : 0 : void SAL_CALL XMLEncryptionTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ )
84 : : throw( Exception, RuntimeException ) {
85 : : // TBD
86 : 0 : } ;
87 : :
88 : : /* XServiceInfo */
89 : 0 : OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException ) {
90 : 0 : return impl_getImplementationName() ;
91 : : }
92 : :
93 : : /* XServiceInfo */
94 : 0 : sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
95 : 0 : Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
96 : 0 : const OUString* pArray = seqServiceNames.getConstArray() ;
97 : 0 : for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
98 : 0 : if( *( pArray + i ) == serviceName )
99 : 0 : return sal_True ;
100 : : }
101 : 0 : return sal_False ;
102 : : }
103 : :
104 : : /* XServiceInfo */
105 : 0 : Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
106 : 0 : return impl_getSupportedServiceNames() ;
107 : : }
108 : :
109 : : //Helper for XServiceInfo
110 : 0 : Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() {
111 : 0 : ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
112 : 0 : Sequence< OUString > seqServiceNames( 1 ) ;
113 : 0 : seqServiceNames.getArray()[0] = OUString("com.sun.star.xml.crypto.XMLEncryptionTemplate") ;
114 : 0 : return seqServiceNames ;
115 : : }
116 : :
117 : 0 : OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
118 : 0 : return OUString("com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl") ;
119 : : }
120 : :
121 : : //Helper for registry
122 : 0 : Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
123 : 0 : return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ;
124 : : }
125 : :
126 : 0 : Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
127 : 0 : return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
128 : : }
129 : :
130 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|