1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
21 #include <rtl/ustring.hxx>
23 #include "xmlsignaturetemplateimpl.hxx"
25 using namespace ::com::sun::star::uno
;
26 using ::com::sun::star::lang::XMultiServiceFactory
;
27 using ::com::sun::star::lang::XSingleServiceFactory
;
29 using ::com::sun::star::xml::wrapper::XXMLElementWrapper
;
30 using ::com::sun::star::xml::crypto::XXMLSignatureTemplate
;
32 XMLSignatureTemplateImpl :: XMLSignatureTemplateImpl( const Reference
< XMultiServiceFactory
>& aFactory
)
34 m_xServiceManager( aFactory
),
35 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN
)
39 XMLSignatureTemplateImpl :: ~XMLSignatureTemplateImpl() {
42 /* XXMLSignatureTemplate */
43 void SAL_CALL
XMLSignatureTemplateImpl :: setTemplate( const Reference
< XXMLElementWrapper
>& aTemplate
)
44 throw( com::sun::star::uno::RuntimeException
, com::sun::star::lang::IllegalArgumentException
, std::exception
)
46 m_xTemplate
= aTemplate
;
49 /* XXMLSignatureTemplate */
50 Reference
< XXMLElementWrapper
> SAL_CALL
XMLSignatureTemplateImpl :: getTemplate()
51 throw (com::sun::star::uno::RuntimeException
, std::exception
)
56 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
)
59 targets
.push_back( aXmlElement
);
62 ::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
)
65 sal_Int32 length
= targets
.size();
66 ::com::sun::star::uno::Sequence
<
67 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::wrapper::XXMLElementWrapper
>
72 for (i
=0; i
<length
; i
++)
74 aTargets
[i
] = targets
[i
];
80 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
)
85 m_xUriBinding
= aUriBinding
;
88 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::crypto::XUriBinding
> SAL_CALL
XMLSignatureTemplateImpl::getBinding()
89 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
94 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
)
101 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL
XMLSignatureTemplateImpl::getStatus( )
102 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
108 OUString SAL_CALL
XMLSignatureTemplateImpl :: getImplementationName() throw( RuntimeException
, std::exception
) {
109 return impl_getImplementationName() ;
113 sal_Bool SAL_CALL
XMLSignatureTemplateImpl :: supportsService( const OUString
& serviceName
) throw( RuntimeException
, std::exception
) {
114 Sequence
< OUString
> seqServiceNames
= getSupportedServiceNames() ;
115 const OUString
* pArray
= seqServiceNames
.getConstArray() ;
116 for( sal_Int32 i
= 0 ; i
< seqServiceNames
.getLength() ; i
++ ) {
117 if( *( pArray
+ i
) == serviceName
)
124 Sequence
< OUString
> SAL_CALL
XMLSignatureTemplateImpl :: getSupportedServiceNames() throw( RuntimeException
, std::exception
) {
125 return impl_getSupportedServiceNames() ;
128 //Helper for XServiceInfo
129 Sequence
< OUString
> XMLSignatureTemplateImpl :: impl_getSupportedServiceNames() {
130 ::osl::Guard
< ::osl::Mutex
> aGuard( ::osl::Mutex::getGlobalMutex() ) ;
131 Sequence
< OUString
> seqServiceNames( 1 ) ;
132 seqServiceNames
[0] = "com.sun.star.xml.crypto.XMLSignatureTemplate";
133 return seqServiceNames
;
136 OUString
XMLSignatureTemplateImpl :: impl_getImplementationName() throw( RuntimeException
) {
137 return OUString("com.sun.star.xml.security.framework.XMLSignatureTemplateImpl") ;
140 //Helper for registry
141 Reference
< XInterface
> SAL_CALL
XMLSignatureTemplateImpl :: impl_createInstance( const Reference
< XMultiServiceFactory
>& aServiceManager
) throw( RuntimeException
) {
142 return Reference
< XInterface
>( *new XMLSignatureTemplateImpl( aServiceManager
) ) ;
145 Reference
< XSingleServiceFactory
> XMLSignatureTemplateImpl :: impl_createFactory( const Reference
< XMultiServiceFactory
>& aServiceManager
) {
146 return ::cppu::createSingleFactory( aServiceManager
, impl_getImplementationName() , impl_createInstance
, impl_getSupportedServiceNames() ) ;
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */