summaryrefslogtreecommitdiff
path: root/xmlsecurity/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-12-06 23:02:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-07 07:55:48 +0100
commit5da74dcdea45c0367a54486fab8b790215022678 (patch)
treec64bdd12616d2bd53ca993fae1d39f95f80e109e /xmlsecurity/source
parentf0b22ccfdd94e557b4c3db5e0aea570341d8830c (diff)
Clean up SerialNumberAdapter implementation
Change-Id: Iebf992544cb71fd2e2f4541a5a63fc962150e390
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r--xmlsecurity/source/xmlsec/serialnumberadapter.cxx99
-rw-r--r--xmlsecurity/source/xmlsec/serialnumberadapter.hxx49
-rw-r--r--xmlsecurity/source/xmlsec/xsec_xmlsec.cxx55
3 files changed, 152 insertions, 51 deletions
diff --git a/xmlsecurity/source/xmlsec/serialnumberadapter.cxx b/xmlsecurity/source/xmlsec/serialnumberadapter.cxx
new file mode 100644
index 000000000000..c441c48b44c6
--- /dev/null
+++ b/xmlsecurity/source/xmlsec/serialnumberadapter.cxx
@@ -0,0 +1,99 @@
+/* -*- 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: */
diff --git a/xmlsecurity/source/xmlsec/serialnumberadapter.hxx b/xmlsecurity/source/xmlsec/serialnumberadapter.hxx
new file mode 100644
index 000000000000..987d00c6986c
--- /dev/null
+++ b/xmlsecurity/source/xmlsec/serialnumberadapter.hxx
@@ -0,0 +1,49 @@
+/* -*- 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: */
diff --git a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx
index 7d50c788fe97..d53d06371952 100644
--- a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx
+++ b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx
@@ -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() );
}
}