Kaydet (Commit) 91af0067 authored tarafından Miklos Vajna's avatar Miklos Vajna

xmlsecurity: remove unused EncryptorImpl

No longer necessary since commit
50669de6 (xmlsecurity: remove unused
xsec_fw_component_getFactory(), 2017-02-02).

Change-Id: Ibbc78888abcd1cb6d7f242c93f28cdaf836cca14
üst b21ba53b
...@@ -36,7 +36,6 @@ $(eval $(call gb_Library_add_exception_objects,xsec_fw,\ ...@@ -36,7 +36,6 @@ $(eval $(call gb_Library_add_exception_objects,xsec_fw,\
xmlsecurity/source/framework/elementcollector \ xmlsecurity/source/framework/elementcollector \
xmlsecurity/source/framework/elementmark \ xmlsecurity/source/framework/elementmark \
xmlsecurity/source/framework/encryptionengine \ xmlsecurity/source/framework/encryptionengine \
xmlsecurity/source/framework/encryptorimpl \
xmlsecurity/source/framework/saxeventkeeperimpl \ xmlsecurity/source/framework/saxeventkeeperimpl \
xmlsecurity/source/framework/securityengine \ xmlsecurity/source/framework/securityengine \
xmlsecurity/source/framework/signaturecreatorimpl \ xmlsecurity/source/framework/signaturecreatorimpl \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "encryptorimpl.hxx"
#include <com/sun/star/xml/crypto/XXMLEncryptionTemplate.hpp>
#include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
using namespace com::sun::star::uno;
namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto;
namespace cssxw = com::sun::star::xml::wrapper;
#define IMPLEMENTATION_NAME "com.sun.star.xml.security.framework.EncryptorImpl"
EncryptorImpl::EncryptorImpl(const Reference<XComponentContext> & xContext) : EncryptorImpl_Base(xContext)
{
m_nReferenceId = -1;
}
EncryptorImpl::~EncryptorImpl()
{
}
bool EncryptorImpl::checkReady() const
/****** EncryptorImpl/checkReady *********************************************
*
* NAME
* checkReady -- checks the conditions for the encryption.
*
* SYNOPSIS
* bReady = checkReady( );
*
* FUNCTION
* checks whether all following conditions are satisfied:
* 1. the result listener is ready;
* 2. the EncryptionEngine is ready.
*
* RESULT
* bReady - true if all conditions are satisfied, false otherwise
******************************************************************************/
{
sal_Int32 nKeyInc = 0;
if (m_nIdOfKeyEC != 0)
{
nKeyInc = 1;
}
return (m_xResultListener.is() &&
(m_nReferenceId != -1) &&
(2+nKeyInc == m_nNumOfResolvedReferences) &&
EncryptionEngine::checkReady());
}
void EncryptorImpl::notifyResultListener() const
/****** DecryptorImpl/notifyResultListener ***********************************
*
* NAME
* notifyResultListener -- notifies the listener about the encryption
* result.
******************************************************************************/
{
Reference< cssxc::sax::XEncryptionResultListener >
xEncryptionResultListener ( m_xResultListener , UNO_QUERY ) ;
xEncryptionResultListener->encrypted( m_nSecurityId, m_nStatus );
}
void EncryptorImpl::startEngine( const Reference<
cssxc::XXMLEncryptionTemplate >&
xEncryptionTemplate)
/****** EncryptorImpl/startEngine ********************************************
*
* NAME
* startEngine -- generates the encryption.
*
* SYNOPSIS
* startEngine( xEncryptionTemplate );
*
* FUNCTION
* generates the encryption element, then if succeeds, updates the link
* of old template element to the new encryption element in
* SAXEventKeeper.
*
* INPUTS
* xEncryptionTemplate - the encryption template to be encrypted.
******************************************************************************/
{
Reference < cssxc::XXMLEncryptionTemplate > xResultTemplate;
Reference< cssxw::XXMLElementWrapper >
xXMLElement = m_xSAXEventKeeper->getElement( m_nReferenceId );
xEncryptionTemplate->setTarget(xXMLElement);
try
{
xResultTemplate = m_xXMLEncryption->encrypt(
xEncryptionTemplate, m_xSecurityEnvironment);
m_nStatus = xResultTemplate->getStatus();
}
catch( Exception& )
{
m_nStatus = cssxc::SecurityOperationStatus_RUNTIMEERROR_FAILED;
}
if (m_nStatus == cssxc::SecurityOperationStatus_OPERATION_SUCCEEDED)
{
Reference < cssxw::XXMLElementWrapper > xResultEncryption
= xResultTemplate->getTemplate();
m_xSAXEventKeeper->setElement(m_nIdOfTemplateEC, xResultEncryption);
m_xSAXEventKeeper->setElement(m_nReferenceId, nullptr);
}
}
/* XReferenceCollector */
void SAL_CALL EncryptorImpl::setReferenceCount(sal_Int32)
{
/*
* dummy method, because there is only one reference in
* encryption, different from signature.
* so the referenceNumber is always 1
*/
}
void SAL_CALL EncryptorImpl::setReferenceId( sal_Int32 id )
{
m_nReferenceId = id;
}
/* XEncryptionResultBroadcaster */
void SAL_CALL EncryptorImpl::addEncryptionResultListener( const Reference< cssxc::sax::XEncryptionResultListener >& listener )
{
m_xResultListener = listener;
tryToPerform();
}
void SAL_CALL EncryptorImpl::removeEncryptionResultListener( const Reference< cssxc::sax::XEncryptionResultListener >&)
{
}
/* XInitialization */
void SAL_CALL EncryptorImpl::initialize( const Sequence< Any >& aArguments )
{
OSL_ASSERT(aArguments.getLength() == 5);
OUString ouTempString;
aArguments[0] >>= ouTempString;
m_nSecurityId = ouTempString.toInt32();
aArguments[1] >>= m_xSAXEventKeeper;
aArguments[2] >>= ouTempString;
m_nIdOfTemplateEC = ouTempString.toInt32();
aArguments[3] >>= m_xSecurityEnvironment;
aArguments[4] >>= m_xXMLEncryption;
}
OUString EncryptorImpl_getImplementationName ()
{
return OUString ( IMPLEMENTATION_NAME );
}
Sequence< OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( )
{
Sequence<OUString> aRet { "com.sun.star.xml.crypto.sax.Encryptor" };
return aRet;
}
Reference< XInterface > SAL_CALL EncryptorImpl_createInstance(
const Reference< cssl::XMultiServiceFactory >& xMSF)
{
return static_cast<cppu::OWeakObject*>(new EncryptorImpl( comphelper::getComponentContext( xMSF ) ));
}
/* XServiceInfo */
OUString SAL_CALL EncryptorImpl::getImplementationName( )
{
return EncryptorImpl_getImplementationName();
}
sal_Bool SAL_CALL EncryptorImpl::supportsService( const OUString& rServiceName )
{
return cppu::supportsService(this, rServiceName);
}
Sequence< OUString > SAL_CALL EncryptorImpl::getSupportedServiceNames( )
{
return EncryptorImpl_getSupportedServiceNames();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_ENCRYPTORIMPL_HXX
#define INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_ENCRYPTORIMPL_HXX
#include <com/sun/star/xml/crypto/sax/XEncryptionResultBroadcaster.hpp>
#include <com/sun/star/xml/crypto/sax/XEncryptionResultListener.hpp>
#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/implbase.hxx>
#include "encryptionengine.hxx"
typedef cppu::ImplInheritanceHelper
<
EncryptionEngine,
css::xml::crypto::sax::XEncryptionResultBroadcaster,
css::xml::crypto::sax::XReferenceCollector,
css::lang::XInitialization,
css::lang::XServiceInfo
> EncryptorImpl_Base;
class EncryptorImpl : public EncryptorImpl_Base
/****** EncryptorImpl.hxx/CLASS EncryptorImpl *********************************
*
* NAME
* EncryptorImpl -- generates an encryption
*
* FUNCTION
* Collects all resources for an encryption generation, then generates the
* encryption by invoking a xmlsec-based encryption bridge component.
******************************************************************************/
{
private:
/*
* the Id of the element to be encrypted.
*/
sal_Int32 m_nReferenceId;
css::uno::Reference<
css::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment;
virtual void notifyResultListener() const override;
virtual bool checkReady() const override;
virtual void startEngine( const css::uno::Reference<
css::xml::crypto::XXMLEncryptionTemplate >&
xEncryptionTemplate) override;
public:
explicit EncryptorImpl(const css::uno::Reference< css::uno::XComponentContext > & xContext);
virtual ~EncryptorImpl() override;
/* XEncryptionResultBroadcaster */
virtual void SAL_CALL addEncryptionResultListener(
const css::uno::Reference<
css::xml::crypto::sax::XEncryptionResultListener >&
listener ) override;
virtual void SAL_CALL removeEncryptionResultListener(
const css::uno::Reference<
css::xml::crypto::sax::XEncryptionResultListener >&
listener ) override;
/* XReferenceCollector */
virtual void SAL_CALL setReferenceCount( sal_Int32 count ) override;
virtual void SAL_CALL setReferenceId( sal_Int32 id ) override;
/* XInitialization */
virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments ) override;
/* XServiceInfo */
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
};
/// @throws css::uno::RuntimeException
OUString EncryptorImpl_getImplementationName();
/// @throws css::uno::RuntimeException
css::uno::Sequence< OUString > SAL_CALL EncryptorImpl_getSupportedServiceNames( );
/// @throws css::uno::Exception
css::uno::Reference< css::uno::XInterface >
SAL_CALL EncryptorImpl_createInstance(
const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment