nss: upgrade to release 3.73
[LibreOffice.git] / xmlsecurity / source / framework / signatureverifierimpl.cxx
blob4daf8d203c6ab5ef83d78063863896cbca5ee2ea
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <framework/signatureverifierimpl.hxx>
22 #include <framework/xmlsignaturetemplateimpl.hxx>
23 #include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <osl/diagnose.h>
26 #include <rtl/ref.hxx>
29 #define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.SignatureVerifierImpl"
31 SignatureVerifierImpl::SignatureVerifierImpl()
32 : SignatureVerifierImpl_Base()
36 SignatureVerifierImpl::~SignatureVerifierImpl()
40 void SignatureVerifierImpl::notifyResultListener() const
41 /****** SignatureVerifierImpl/notifyResultListener ***************************
43 * NAME
44 * notifyResultListener -- notifies the listener about the verify result.
45 ******************************************************************************/
47 css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >
48 xSignatureVerifyResultListener ( m_xResultListener , css::uno::UNO_QUERY ) ;
50 xSignatureVerifyResultListener->signatureVerified( m_nSecurityId, m_nStatus );
53 void SignatureVerifierImpl::startEngine( const rtl::Reference<XMLSignatureTemplateImpl>& xSignatureTemplate)
54 /****** SignatureVerifierImpl/startEngine ************************************
56 * NAME
57 * startEngine -- verifies the signature.
59 * INPUTS
60 * xSignatureTemplate - the signature template (along with all referenced
61 * elements) to be verified.
62 ******************************************************************************/
64 css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > xResultTemplate;
65 try
67 xResultTemplate = m_xXMLSignature->validate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate.get()), m_xXMLSecurityContext);
68 m_nStatus = xResultTemplate->getStatus();
70 catch( css::uno::Exception& )
72 m_nStatus = css::xml::crypto::SecurityOperationStatus_RUNTIMEERROR_FAILED;
76 /* XSignatureVerifyResultBroadcaster */
77 void SAL_CALL SignatureVerifierImpl::addSignatureVerifyResultListener(
78 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >& listener )
80 m_xResultListener = listener;
81 tryToPerform();
84 void SAL_CALL SignatureVerifierImpl::removeSignatureVerifyResultListener(
85 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >&)
89 /* XInitialization */
90 void SAL_CALL SignatureVerifierImpl::initialize(
91 const css::uno::Sequence< css::uno::Any >& aArguments )
93 OSL_ASSERT(aArguments.getLength() == 5);
95 OUString ouTempString;
97 aArguments[0] >>= ouTempString;
98 m_nSecurityId = ouTempString.toInt32();
99 aArguments[1] >>= m_xSAXEventKeeper;
100 aArguments[2] >>= ouTempString;
101 m_nIdOfTemplateEC = ouTempString.toInt32();
102 aArguments[3] >>= m_xXMLSecurityContext;
103 aArguments[4] >>= m_xXMLSignature;
107 OUString SignatureVerifierImpl_getImplementationName ()
109 return IMPLEMENTATION_NAME;
112 css::uno::Sequence< OUString > SignatureVerifierImpl_getSupportedServiceNames( )
114 css::uno::Sequence<OUString> aRet { "com.sun.star.xml.crypto.sax.SignatureVerifier" };
115 return aRet;
118 /* XServiceInfo */
119 OUString SAL_CALL SignatureVerifierImpl::getImplementationName( )
121 return SignatureVerifierImpl_getImplementationName();
124 sal_Bool SAL_CALL SignatureVerifierImpl::supportsService( const OUString& rServiceName )
126 return cppu::supportsService(this, rServiceName);
129 css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServiceNames( )
131 return SignatureVerifierImpl_getSupportedServiceNames();
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */