Kaydet (Commit) 5da74dcd authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up SerialNumberAdapter implementation

Change-Id: Iebf992544cb71fd2e2f4541a5a63fc962150e390
üst f0b22ccf
......@@ -84,6 +84,7 @@ $(eval $(call gb_Library_add_exception_objects,xsec_xmlsec,\
xmlsecurity/source/xmlsec/diagnose \
xmlsecurity/source/xmlsec/errorcallback \
xmlsecurity/source/xmlsec/saxhelper \
xmlsecurity/source/xmlsec/serialnumberadapter \
xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl \
xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl \
xmlsecurity/source/xmlsec/xmlstreamio \
......
/* -*- 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 "sal/config.h"
#include "boost/noncopyable.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/security/XSerialNumberAdapter.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/supportsservice.hxx"
#include "cppuhelper/weak.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "xmlsecurity/biginteger.hxx"
#include "serialnumberadapter.hxx"
namespace {
class Service:
public cppu::WeakImplHelper2<
css::lang::XServiceInfo, css::security::XSerialNumberAdapter >,
private boost::noncopyable
{
public:
Service() {}
private:
virtual ~Service() {}
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{ return xml_security::serial_number_adapter::implementationName(); }
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{ return cppu::supportsService(this, ServiceName); }
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException)
{ return xml_security::serial_number_adapter::serviceNames(); }
virtual OUString SAL_CALL toString(
css::uno::Sequence< sal_Int8 > const & SerialNumber)
throw (css::uno::RuntimeException)
{ return bigIntegerToNumericString(SerialNumber); }
virtual css::uno::Sequence< sal_Int8 > SAL_CALL toSequence(
OUString const & SerialNumber)
throw (css::uno::RuntimeException)
{ return numericStringToBigInteger(SerialNumber); }
};
}
css::uno::Reference< css::uno::XInterface >
xml_security::serial_number_adapter::create(
css::uno::Reference< css::uno::XComponentContext > const &)
{
return static_cast< cppu::OWeakObject * >(new Service);
}
OUString xml_security::serial_number_adapter::implementationName()
throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.comp.security.SerialNumberAdapter");
}
css::uno::Sequence< OUString >
xml_security::serial_number_adapter::serviceNames()
throw (css::uno::RuntimeException)
{
css::uno::Sequence< OUString > s(1);
s[0] = "com.sun.star.security.SerialNumberAdapter";
return s;
}
/* 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_XMLSEC_SERIALNUMBERADAPTER_HXX
#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_SERIALNUMBERADAPTER_HXX
#include "sal/config.h"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/Sequence.hxx"
#include "sal/types.h"
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
class XInterface;
} } } }
namespace rtl { class OUString; }
namespace xml_security { namespace serial_number_adapter {
css::uno::Reference< css::uno::XInterface > SAL_CALL create(
css::uno::Reference< css::uno::XComponentContext > const &);
rtl::OUString implementationName() throw (css::uno::RuntimeException);
css::uno::Sequence< rtl::OUString > serviceNames()
throw (css::uno::RuntimeException);
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -19,64 +19,17 @@
#include <sal/config.h>
#include <stdio.h>
#include <osl/mutex.hxx>
#include <osl/thread.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/security/XSerialNumberAdapter.hpp>
#include "serialnumberadapter.hxx"
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include "xmldocumentwrapper_xmlsecimpl.hxx"
#include "xmlsecurity/biginteger.hxx"
using namespace ::rtl;
using namespace ::cppu;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
namespace
{
class SerialNumberAdapterImpl : public WeakImplHelper1<
::com::sun::star::security::XSerialNumberAdapter >
{
virtual OUString SAL_CALL toString( const Sequence< sal_Int8 >& rSerialNumber )
throw (RuntimeException)
{
return bigIntegerToNumericString(rSerialNumber);
}
virtual Sequence< sal_Int8 > SAL_CALL toSequence( const OUString& rSerialNumber )
throw (RuntimeException)
{
return numericStringToBigInteger(rSerialNumber);
}
};
OUString SerialNumberAdapterImpl_getImplementationName()
throw (RuntimeException)
{
return OUString( "com.sun.star.security.SerialNumberAdapter");
}
Sequence< OUString > SerialNumberAdapterImpl_getSupportedServiceNames()
throw (RuntimeException)
{
Sequence < OUString > aRet(1);
OUString* pArray = aRet.getArray();
pArray[0] = OUString( "com.sun.star.security.SerialNumberAdapter" );
return aRet;
}
Reference< XInterface > SerialNumberAdapterImpl_createInstance(
const Reference< XComponentContext > &) throw( Exception )
{
return Reference< XInterface >( *new SerialNumberAdapterImpl() );
}
}
extern "C"
{
......@@ -107,12 +60,12 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL xsec_xmlsec_component_getFactory( const sal_
OUString::createFromAscii( pImplName ),
XMLDocumentWrapper_XmlSecImpl_createInstance, XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames() ) );
}
else if( SerialNumberAdapterImpl_getImplementationName().equals( OUString::createFromAscii( pImplName ) ) )
else if( xml_security::serial_number_adapter::implementationName().equals( OUString::createFromAscii( pImplName ) ) )
{
xFactory = ::cppu::createSingleComponentFactory(
SerialNumberAdapterImpl_createInstance,
xml_security::serial_number_adapter::create,
OUString::createFromAscii( pImplName ),
SerialNumberAdapterImpl_getSupportedServiceNames() );
xml_security::serial_number_adapter::serviceNames() );
}
}
......
......@@ -19,7 +19,7 @@
<component loader="com.sun.star.loader.SharedLibrary" prefix="xsec_xmlsec"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.security.SerialNumberAdapter">
<implementation name="com.sun.star.comp.security.SerialNumberAdapter">
<service name="com.sun.star.security.SerialNumberAdapter"/>
</implementation>
<implementation name="com.sun.star.xml.security.bridge.xmlsec.SEInitializer_NssImpl">
......
......@@ -19,7 +19,7 @@
<component loader="com.sun.star.loader.SharedLibrary" prefix="xsec_xmlsec"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.security.SerialNumberAdapter">
<implementation name="com.sun.star.comp.security.SerialNumberAdapter">
<service name="com.sun.star.security.SerialNumberAdapter"/>
</implementation>
<implementation name="com.sun.star.xml.security.bridge.xmlsec.NSSInitializer_NssImpl">
......
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