cid#1640468 Dereference after null check
[LibreOffice.git] / xmlsecurity / source / framework / signatureverifierimpl.cxx
blobb96050d5c0bdc8fc801ea93d217c3e8a5c054544
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 SignatureVerifierImpl::SignatureVerifierImpl()
33 SignatureVerifierImpl::~SignatureVerifierImpl()
37 void SignatureVerifierImpl::notifyResultListener() const
38 /****** SignatureVerifierImpl/notifyResultListener ***************************
40 * NAME
41 * notifyResultListener -- notifies the listener about the verify result.
42 ******************************************************************************/
44 css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >
45 xSignatureVerifyResultListener ( m_xResultListener , css::uno::UNO_QUERY ) ;
47 xSignatureVerifyResultListener->signatureVerified( m_nSecurityId, m_nStatus );
50 void SignatureVerifierImpl::startEngine( const rtl::Reference<XMLSignatureTemplateImpl>& xSignatureTemplate)
51 /****** SignatureVerifierImpl/startEngine ************************************
53 * NAME
54 * startEngine -- verifies the signature.
56 * INPUTS
57 * xSignatureTemplate - the signature template (along with all referenced
58 * elements) to be verified.
59 ******************************************************************************/
61 css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > xResultTemplate;
62 try
64 xResultTemplate = m_xXMLSignature->validate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate), m_xXMLSecurityContext);
65 m_nStatus = xResultTemplate->getStatus();
67 catch( css::uno::Exception& )
69 m_nStatus = css::xml::crypto::SecurityOperationStatus_RUNTIMEERROR_FAILED;
73 /* XSignatureVerifyResultBroadcaster */
74 void SAL_CALL SignatureVerifierImpl::addSignatureVerifyResultListener(
75 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >& listener )
77 m_xResultListener = listener;
78 tryToPerform();
81 void SAL_CALL SignatureVerifierImpl::removeSignatureVerifyResultListener(
82 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >&)
86 /* XInitialization */
87 void SAL_CALL SignatureVerifierImpl::initialize(
88 const css::uno::Sequence< css::uno::Any >& aArguments )
90 OSL_ASSERT(aArguments.getLength() == 5);
92 OUString ouTempString;
94 aArguments[0] >>= ouTempString;
95 m_nSecurityId = ouTempString.toInt32();
96 aArguments[1] >>= m_xSAXEventKeeper;
97 aArguments[2] >>= ouTempString;
98 m_nIdOfTemplateEC = ouTempString.toInt32();
99 aArguments[3] >>= m_xXMLSecurityContext;
100 aArguments[4] >>= m_xXMLSignature;
104 OUString SignatureVerifierImpl_getImplementationName ()
106 return u"com.sun.star.xml.security.framework.SignatureVerifierImpl"_ustr;
109 css::uno::Sequence< OUString > SignatureVerifierImpl_getSupportedServiceNames( )
111 return { u"com.sun.star.xml.crypto.sax.SignatureVerifier"_ustr };
114 /* XServiceInfo */
115 OUString SAL_CALL SignatureVerifierImpl::getImplementationName( )
117 return SignatureVerifierImpl_getImplementationName();
120 sal_Bool SAL_CALL SignatureVerifierImpl::supportsService( const OUString& rServiceName )
122 return cppu::supportsService(this, rServiceName);
125 css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServiceNames( )
127 return SignatureVerifierImpl_getSupportedServiceNames();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */