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