LibreOffice Module xmlsecurity (master) 1
signatureverifierimpl.cxx
Go to the documentation of this file.
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
23#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
25#include <osl/diagnose.h>
26#include <rtl/ref.hxx>
27
28
30{
31}
32
34{
35}
36
38/****** SignatureVerifierImpl/notifyResultListener ***************************
39 *
40 * NAME
41 * notifyResultListener -- notifies the listener about the verify result.
42 ******************************************************************************/
43{
44 css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >
45 xSignatureVerifyResultListener ( m_xResultListener , css::uno::UNO_QUERY ) ;
46
47 xSignatureVerifyResultListener->signatureVerified( m_nSecurityId, m_nStatus );
48}
49
51/****** SignatureVerifierImpl/startEngine ************************************
52 *
53 * NAME
54 * startEngine -- verifies the signature.
55 *
56 * INPUTS
57 * xSignatureTemplate - the signature template (along with all referenced
58 * elements) to be verified.
59 ******************************************************************************/
60{
61 css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > xResultTemplate;
62 try
63 {
64 xResultTemplate = m_xXMLSignature->validate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate), m_xXMLSecurityContext);
65 m_nStatus = xResultTemplate->getStatus();
66 }
67 catch( css::uno::Exception& )
68 {
69 m_nStatus = css::xml::crypto::SecurityOperationStatus_RUNTIMEERROR_FAILED;
70 }
71}
72
73/* XSignatureVerifyResultBroadcaster */
75 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >& listener )
76{
77 m_xResultListener = listener;
78 tryToPerform();
79}
80
82 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >&)
83{
84}
85
86/* XInitialization */
88 const css::uno::Sequence< css::uno::Any >& aArguments )
89{
90 OSL_ASSERT(aArguments.getLength() == 5);
91
92 OUString ouTempString;
93
94 aArguments[0] >>= ouTempString;
95 m_nSecurityId = ouTempString.toInt32();
96 aArguments[1] >>= m_xSAXEventKeeper;
97 aArguments[2] >>= ouTempString;
98 m_nIdOfTemplateEC = ouTempString.toInt32();
100 aArguments[4] >>= m_xXMLSignature;
101}
102
103
105{
106 return "com.sun.star.xml.security.framework.SignatureVerifierImpl";
107}
108
109css::uno::Sequence< OUString > SignatureVerifierImpl_getSupportedServiceNames( )
110{
111 return { "com.sun.star.xml.crypto.sax.SignatureVerifier" };
112}
113
114/* XServiceInfo */
116{
118}
119
120sal_Bool SAL_CALL SignatureVerifierImpl::supportsService( const OUString& rServiceName )
121{
122 return cppu::supportsService(this, rServiceName);
123}
124
125css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServiceNames( )
126{
128}
129
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
oslInterlockedCount m_nStatus
virtual void SAL_CALL removeSignatureVerifyResultListener(const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener > &listener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL addSignatureVerifyResultListener(const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener > &listener) override
virtual void notifyResultListener() const override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::xml::crypto::XXMLSecurityContext > m_xXMLSecurityContext
virtual void startEngine(const rtl::Reference< XMLSignatureTemplateImpl > &xSignatureTemplate) override
virtual ~SignatureVerifierImpl() override
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Sequence< OUString > SignatureVerifierImpl_getSupportedServiceNames()
OUString SignatureVerifierImpl_getImplementationName()
unsigned char sal_Bool