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 :
28 : using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
29 : using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
30 :
31 1 : XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
32 : : m_xTemplate( NULL ),
33 : m_xTarget( NULL ),
34 : m_xServiceManager( aFactory ),
35 1 : m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) {
36 1 : }
37 :
38 2 : XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
39 2 : }
40 :
41 : /* XXMLEncryptionTemplate */
42 0 : void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
43 : throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException, std::exception)
44 : {
45 0 : m_xTemplate = aTemplate ;
46 0 : }
47 :
48 : /* XXMLEncryptionTemplate */
49 0 : Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
50 : throw (com::sun::star::uno::RuntimeException, std::exception)
51 : {
52 0 : return m_xTemplate ;
53 : }
54 :
55 : /* XXMLEncryptionTemplate */
56 0 : void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
57 : throw( com::sun::star::lang::IllegalArgumentException, std::exception ) {
58 0 : m_xTarget = aTarget ;
59 0 : }
60 :
61 : /* XXMLEncryptionTemplate */
62 0 : Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
63 : throw (com::sun::star::uno::RuntimeException, std::exception)
64 : {
65 0 : return m_xTarget ;
66 : }
67 :
68 0 : void SAL_CALL XMLEncryptionTemplateImpl::setStatus(
69 : ::com::sun::star::xml::crypto::SecurityOperationStatus status )
70 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
71 : {
72 0 : m_nStatus = status;
73 0 : }
74 :
75 0 : ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( )
76 : throw (::com::sun::star::uno::RuntimeException, std::exception)
77 : {
78 0 : return m_nStatus;
79 : }
80 :
81 : /* XServiceInfo */
82 1 : OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException, std::exception ) {
83 1 : return impl_getImplementationName() ;
84 : }
85 :
86 : /* XServiceInfo */
87 0 : sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException, std::exception ) {
88 0 : Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
89 0 : const OUString* pArray = seqServiceNames.getConstArray() ;
90 0 : for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
91 0 : if( *( pArray + i ) == serviceName )
92 0 : return sal_True ;
93 : }
94 0 : return sal_False ;
95 : }
96 :
97 : /* XServiceInfo */
98 1 : Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException, std::exception ) {
99 1 : return impl_getSupportedServiceNames() ;
100 : }
101 :
102 : //Helper for XServiceInfo
103 2 : Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() {
104 2 : ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
105 2 : Sequence< OUString > seqServiceNames( 1 ) ;
106 2 : seqServiceNames[0] = "com.sun.star.xml.crypto.XMLEncryptionTemplate";
107 2 : return seqServiceNames;
108 : }
109 :
110 9 : OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
111 9 : return OUString("com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl") ;
112 : }
113 :
114 : //Helper for registry
115 1 : Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
116 1 : return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ;
117 : }
118 :
119 1 : Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
120 1 : return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
121 : }
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|