Debian Codegraph @

xmlsecurity/source/framework/signatureverifierimpl.cxx

raw
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
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>
27
28
29 SignatureVerifierImpl::SignatureVerifierImpl()
30 {
31 }
32
33 SignatureVerifierImpl::~SignatureVerifierImpl()
34 {
35 }
36
37 void SignatureVerifierImpl::notifyResultListener() const
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
50 void SignatureVerifierImpl::startEngine( const rtl::Reference<XMLSignatureTemplateImpl>& xSignatureTemplate)
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 */
74 void SAL_CALL SignatureVerifierImpl::addSignatureVerifyResultListener(
75 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >& listener )
76 {
77 m_xResultListener = listener;
78 tryToPerform();
79 }
80
81 void SAL_CALL SignatureVerifierImpl::removeSignatureVerifyResultListener(
82 const css::uno::Reference< css::xml::crypto::sax::XSignatureVerifyResultListener >&)
83 {
84 }
85
86 /* XInitialization */
87 void SAL_CALL SignatureVerifierImpl::initialize(
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();
99 aArguments[3] >>= m_xXMLSecurityContext;
100 aArguments[4] >>= m_xXMLSignature;
101 }
102
103
104 OUString SignatureVerifierImpl_getImplementationName ()
105 {
106 return u"com.sun.star.xml.security.framework.SignatureVerifierImpl"_ustr;
107 }
108
109 css::uno::Sequence< OUString > SignatureVerifierImpl_getSupportedServiceNames( )
110 {
111 return { u"com.sun.star.xml.crypto.sax.SignatureVerifier"_ustr };
112 }
113
114 /* XServiceInfo */
115 OUString SAL_CALL SignatureVerifierImpl::getImplementationName( )
116 {
117 return SignatureVerifierImpl_getImplementationName();
118 }
119
120 sal_Bool SAL_CALL SignatureVerifierImpl::supportsService( const OUString& rServiceName )
121 {
122 return cppu::supportsService(this, rServiceName);
123 }
124
125 css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServiceNames( )
126 {
127 return SignatureVerifierImpl_getSupportedServiceNames();
128 }
129
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */