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/ustring.hxx>
22 : : #include <rtl/uuid.h>
23 : : #include "xmlsignaturetemplateimpl.hxx"
24 : :
25 : : using namespace ::com::sun::star::uno ;
26 : : using ::com::sun::star::lang::XMultiServiceFactory ;
27 : : using ::com::sun::star::lang::XSingleServiceFactory ;
28 : : using ::rtl::OUString ;
29 : :
30 : : using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
31 : : using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ;
32 : :
33 : 0 : XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
34 : : :m_xTemplate( NULL ),
35 : : m_xServiceManager( aFactory ),
36 : 0 : m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN )
37 : : {
38 : 0 : }
39 : :
40 : 0 : XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() {
41 : 0 : }
42 : :
43 : : /* XXMLSignatureTemplate */
44 : 0 : void SAL_CALL XMLSignatureTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
45 : : throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
46 : : {
47 : 0 : m_xTemplate = aTemplate ;
48 : 0 : }
49 : :
50 : : /* XXMLSignatureTemplate */
51 : 0 : Reference< XXMLElementWrapper > SAL_CALL XMLSignatureTemplateImpl :: getTemplate()
52 : : throw (com::sun::star::uno::RuntimeException)
53 : : {
54 : 0 : return m_xTemplate ;
55 : : }
56 : :
57 : 0 : void SAL_CALL XMLSignatureTemplateImpl :: setTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >& aXmlElement )
58 : : throw( com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException)
59 : : {
60 : 0 : targets.push_back( aXmlElement );
61 : 0 : }
62 : :
63 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl :: getTargets()
64 : : throw (com::sun::star::uno::RuntimeException)
65 : : {
66 : 0 : sal_Int32 length = targets.size();
67 : : ::com::sun::star::uno::Sequence<
68 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::wrapper::XXMLElementWrapper >
69 : 0 : > aTargets (length);
70 : :
71 : : sal_Int32 i;
72 : :
73 : 0 : for (i=0; i<length; i++)
74 : : {
75 : 0 : aTargets[i] = targets[i];
76 : : }
77 : :
78 : 0 : return aTargets;
79 : : }
80 : :
81 : 0 : void SAL_CALL XMLSignatureTemplateImpl::setBinding(
82 : : const ::com::sun::star::uno::Reference<
83 : : ::com::sun::star::xml::crypto::XUriBinding >& aUriBinding )
84 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
85 : : {
86 : 0 : m_xUriBinding = aUriBinding;
87 : 0 : }
88 : :
89 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XUriBinding > SAL_CALL XMLSignatureTemplateImpl::getBinding()
90 : : throw (::com::sun::star::uno::RuntimeException)
91 : : {
92 : 0 : return m_xUriBinding;
93 : : }
94 : :
95 : 0 : void SAL_CALL XMLSignatureTemplateImpl::setStatus(
96 : : ::com::sun::star::xml::crypto::SecurityOperationStatus status )
97 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
98 : : {
99 : 0 : m_nStatus = status;
100 : 0 : }
101 : :
102 : 0 : ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLSignatureTemplateImpl::getStatus( )
103 : : throw (::com::sun::star::uno::RuntimeException)
104 : : {
105 : 0 : return m_nStatus;
106 : : }
107 : :
108 : : /* XInitialization */
109 : 0 : void SAL_CALL XMLSignatureTemplateImpl :: initialize( const Sequence< Any >& /*aArguments*/ ) throw( Exception, RuntimeException ) {
110 : : // TBD
111 : 0 : } ;
112 : :
113 : : /* XServiceInfo */
114 : 0 : OUString SAL_CALL XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException ) {
115 : 0 : return impl_getImplementationName() ;
116 : : }
117 : :
118 : : /* XServiceInfo */
119 : 0 : sal_Bool SAL_CALL XMLSignatureTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException ) {
120 : 0 : Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
121 : 0 : const OUString* pArray = seqServiceNames.getConstArray() ;
122 : 0 : for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
123 : 0 : if( *( pArray + i ) == serviceName )
124 : 0 : return sal_True ;
125 : : }
126 : 0 : return sal_False ;
127 : : }
128 : :
129 : : /* XServiceInfo */
130 : 0 : Sequence< OUString > SAL_CALL XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException ) {
131 : 0 : return impl_getSupportedServiceNames() ;
132 : : }
133 : :
134 : : //Helper for XServiceInfo
135 : 0 : Sequence< OUString > XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() {
136 : 0 : ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
137 : 0 : Sequence< OUString > seqServiceNames( 1 ) ;
138 : 0 : seqServiceNames.getArray()[0] = OUString("com.sun.star.xml.crypto.XMLSignatureTemplate") ;
139 : 0 : return seqServiceNames ;
140 : : }
141 : :
142 : 0 : OUString XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
143 : 0 : return OUString("com.sun.star.xml.security.framework.XMLSignatureTemplateImpl") ;
144 : : }
145 : :
146 : : //Helper for registry
147 : 0 : Reference< XInterface > SAL_CALL XMLSignatureTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
148 : 0 : return Reference< XInterface >( *new XMLSignatureTemplateImpl( aServiceManager ) ) ;
149 : : }
150 : :
151 : 0 : Reference< XSingleServiceFactory > XMLSignatureTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
152 : 0 : return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
153 : : }
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|