From cb3925dad790f56d1b24a1842783aea2a7debcf1 Mon Sep 17 00:00:00 2001
From: Pawel GUTOWSKI <Pawel.GUTOWSKI@ext.ec.europa.eu>
Date: Fri, 12 Jan 2018 17:28:28 +0100
Subject: [PATCH] EDELIVERY-3049 EDELIVERY-2304 Fixed UTF-8 issue in
 ServiceGroup Extension element, romoved util package since all classes were
 already refactored in a meanwhile

---
 .../smp}/BCryptPasswordHash.java              |  8 ++--
 .../smp/conversion/ExtensionConverter.java}   | 36 +++++++++---------
 .../smp/conversion/ServiceGroupConverter.java |  8 ++--
 .../smp}/BCryptPasswordHashTest.java          |  7 ++--
 .../conversion/ExtensionConverterTest.java}   | 37 +++++++++++++++----
 .../conversion/ServiceGroupConverterTest.java |  2 +-
 .../ServiceMetadataConverterTest.java         |  2 +-
 .../ServiceGroupServiceIntegrationTest.java   |  4 +-
 .../ServiceMetadataIntegrationTest.java       |  4 +-
 .../services/ServiceMetadataSignerTest.java   |  9 +----
 .../smp/testutil}/SignatureUtil.java          |  7 ++--
 .../smp/testutil}/X509KeySelector.java        |  6 +--
 .../smp/testutil}/XmlTestUtils.java           |  7 ++--
 13 files changed, 76 insertions(+), 61 deletions(-)
 rename smp-server-library/src/main/java/eu/europa/ec/{cipa/smp/server/security => edelivery/smp}/BCryptPasswordHash.java (71%)
 rename smp-server-library/src/main/java/eu/europa/ec/{cipa/smp/server/util/ExtensionUtils.java => edelivery/smp/conversion/ExtensionConverter.java} (76%)
 rename smp-server-library/src/test/java/eu/europa/ec/{cipa/smp/server/security => edelivery/smp}/BCryptPasswordHashTest.java (88%)
 rename smp-server-library/src/test/java/eu/europa/ec/{cipa/smp/server/util/ExtensionUtilsTest.java => edelivery/smp/conversion/ExtensionConverterTest.java} (74%)
 rename smp-server-library/src/test/java/eu/europa/ec/{cipa/smp/server/security => edelivery/smp/testutil}/SignatureUtil.java (97%)
 rename smp-server-library/src/test/java/eu/europa/ec/{cipa/smp/server/security => edelivery/smp/testutil}/X509KeySelector.java (91%)
 rename smp-server-library/src/test/java/eu/europa/ec/{cipa/smp/server/util => edelivery/smp/testutil}/XmlTestUtils.java (91%)

diff --git a/smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHash.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/BCryptPasswordHash.java
similarity index 71%
rename from smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHash.java
rename to smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/BCryptPasswordHash.java
index 202d30cdd..a5c529f80 100644
--- a/smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHash.java
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/BCryptPasswordHash.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,11 +11,13 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.security;
+package eu.europa.ec.edelivery.smp;
 
 import org.springframework.security.crypto.bcrypt.BCrypt;
 
 /**
+ * Utilitiy class that can be used from commandline by SMP administrators if they want to calculate BCrypt hash.
+ *
  * Created by gutowpa on 22/02/2017.
  */
 public class BCryptPasswordHash {
diff --git a/smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtils.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverter.java
similarity index 76%
rename from smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtils.java
rename to smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverter.java
index 6059ca4a3..817d180b8 100644
--- a/smp-server-library/src/main/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtils.java
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverter.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,16 +11,13 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.util;
+package eu.europa.ec.edelivery.smp.conversion;
 
 import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ExtensionType;
+import org.springframework.util.StreamUtils;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.*;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.namespace.QName;
@@ -31,15 +28,16 @@ import javax.xml.transform.stream.StreamSource;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.util.ArrayList;
+import java.io.UnsupportedEncodingException;
 import java.util.Collections;
 import java.util.List;
+
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 /**
  * Created by migueti on 13/02/2017.
  */
-public class ExtensionUtils {
+public class ExtensionConverter {
 
     private static final String WRAPPED_FORMAT = "<ExtensionsWrapper xmlns=\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\">%s</ExtensionsWrapper>";
 
@@ -51,24 +49,24 @@ public class ExtensionUtils {
 
     private static final QName EXT_TYPE_QNAME = new QName("http://docs.oasis-open.org/bdxr/ns/SMP/2016/05", "Extension");
 
-    public static String marshalExtensions(List<ExtensionType> extensions) throws JAXBException, XMLStreamException {
+    protected static String marshalExtensions(List<ExtensionType> extensions) throws JAXBException, XMLStreamException, UnsupportedEncodingException {
         if (extensions == null) {
             return null;
         }
         StringBuilder stringBuilder = new StringBuilder();
         for (ExtensionType aExtension : extensions) {
-            stringBuilder.append(ExtensionUtils.marshalExtension(aExtension));
+            stringBuilder.append(ExtensionConverter.marshalExtension(aExtension));
         }
         return stringBuilder.toString();
     }
 
-    private static String marshalExtension(ExtensionType extension) throws JAXBException, XMLStreamException {
-        if(extension == null) {
+    private static String marshalExtension(ExtensionType extension) throws JAXBException, XMLStreamException, UnsupportedEncodingException {
+        if (extension == null) {
             return null;
         }
         JAXBContext jaxbContext = JAXBContext.newInstance(ExtensionType.class);
         Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
-        JAXBElement aJaxbElement = new JAXBElement(EXT_TYPE_QNAME, ExtensionType.class, extension);
+        JAXBElement jaxbElement = new JAXBElement(EXT_TYPE_QNAME, ExtensionType.class, extension);
         jaxbMarshaller.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         XMLOutputFactory xof = XMLOutputFactory.newFactory();
@@ -77,19 +75,19 @@ public class ExtensionUtils {
         try {
             xmlStreamWriter = xof.createXMLStreamWriter(baos);
             xsw = new PrettyPrintXMLStreamWriter(xmlStreamWriter, 4);
-            jaxbMarshaller.marshal(aJaxbElement, xsw);
+            jaxbMarshaller.marshal(jaxbElement, xsw);
         } finally {
-            if(xmlStreamWriter != null) {
+            if (xmlStreamWriter != null) {
                 xmlStreamWriter.close();
             }
             if (xsw != null) {
                 xsw.close();
             }
         }
-        return baos.toString();
+        return baos.toString(UTF_8.name());
     }
 
-    public static List<ExtensionType> unmarshalExtensions(String xml) throws JAXBException {
+    protected static List<ExtensionType> unmarshalExtensions(String xml) throws JAXBException {
         String wrappedExtensionsStr = String.format(WRAPPED_FORMAT, xml);
         InputStream inStream = new ByteArrayInputStream(wrappedExtensionsStr.getBytes(UTF_8));
         JAXBContext jaxbContext = JAXBContext.newInstance(ExtensionsWrapper.class);
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
index 886741f9e..f7ddf2b5f 100644
--- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
@@ -16,7 +16,6 @@ package eu.europa.ec.edelivery.smp.conversion;
 import eu.europa.ec.edelivery.smp.data.model.DBServiceGroupId;
 import eu.europa.ec.edelivery.smp.exceptions.ConversionException;
 import eu.europa.ec.edelivery.smp.exceptions.XmlParsingException;
-import eu.europa.ec.cipa.smp.server.util.ExtensionUtils;
 import eu.europa.ec.edelivery.smp.data.model.DBServiceGroup;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.*;
 import org.w3c.dom.Document;
@@ -32,6 +31,7 @@ import javax.xml.stream.XMLStreamException;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -72,7 +72,7 @@ public class ServiceGroupConverter {
         ParticipantIdentifierType identifier = new ParticipantIdentifierType(dbServiceGroup.getId().getBusinessIdentifier(), dbServiceGroup.getId().getBusinessIdentifierScheme());
         serviceGroup.setParticipantIdentifier(identifier);
         try {
-            List<ExtensionType> extensions = ExtensionUtils.unmarshalExtensions(dbServiceGroup.getExtension());
+            List<ExtensionType> extensions = ExtensionConverter.unmarshalExtensions(dbServiceGroup.getExtension());
             serviceGroup.getExtensions().addAll(extensions);
         } catch (JAXBException e) {
             throw new ConversionException(e);
@@ -95,8 +95,8 @@ public class ServiceGroupConverter {
 
     public static String extractExtensionsPayload(ServiceGroup serviceGroup) {
         try {
-            return ExtensionUtils.marshalExtensions(serviceGroup.getExtensions());
-        } catch (JAXBException | XMLStreamException e) {
+            return ExtensionConverter.marshalExtensions(serviceGroup.getExtensions());
+        } catch (JAXBException | XMLStreamException | UnsupportedEncodingException e) {
             throw new ConversionException(e);
         }
     }
diff --git a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHashTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/BCryptPasswordHashTest.java
similarity index 88%
rename from smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHashTest.java
rename to smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/BCryptPasswordHashTest.java
index 45bbe4d34..456d5d66a 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/BCryptPasswordHashTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/BCryptPasswordHashTest.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,8 +11,9 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.security;
+package eu.europa.ec.edelivery.smp;
 
+import eu.europa.ec.edelivery.smp.BCryptPasswordHash;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtilsTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverterTest.java
similarity index 74%
rename from smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtilsTest.java
rename to smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverterTest.java
index c3eeb4a52..c716f865d 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/ExtensionUtilsTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ExtensionConverterTest.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,8 +11,9 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.util;
+package eu.europa.ec.edelivery.smp.conversion;
 
+import eu.europa.ec.edelivery.smp.testutil.XmlTestUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ExtensionType;
@@ -22,21 +23,26 @@ import org.xmlunit.matchers.CompareMatcher;
 import javax.xml.bind.JAXBException;
 import javax.xml.stream.XMLStreamException;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
 /**
  * Created by migueti on 13/02/2017.
  */
-public class ExtensionUtilsTest {
+public class ExtensionConverterTest {
 
     private static final String WRAPPED_FORMAT = "<ExtensionsWrapper xmlns=\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\">%s</ExtensionsWrapper>";
 
     private static final String RES_PATH = "/eu/europa/ec/cipa/smp/server/util/";
 
+    private static final String UTF8_SEQUENCE = "ẞßÄäËëÏïÖöÜüẄẅŸÿЁёЇїӜӝ-Zażółć gęślą jaźń-ÆæØøÅå-ÀÆÇßãÿαΩƒ";
+
     @Test
     public void testMarshalOneExtension() throws JAXBException, XMLStreamException, IOException, SAXException {
         // given
@@ -44,7 +50,7 @@ public class ExtensionUtilsTest {
         String inputDoc = XmlTestUtils.loadDocumentAsString(RES_PATH + "extensionMarshal.xml");
 
         // when
-        String xmlResult = ExtensionUtils.marshalExtensions(list);
+        String xmlResult = ExtensionConverter.marshalExtensions(list);
 
         // then
         assertThat(xmlResult, CompareMatcher.isIdenticalTo(inputDoc));
@@ -57,7 +63,7 @@ public class ExtensionUtilsTest {
         String inputDoc = XmlTestUtils.loadDocumentAsString(RES_PATH + "extensionMarshalMore.xml");
 
         // when
-        String xmlResult = ExtensionUtils.marshalExtensions(list);
+        String xmlResult = ExtensionConverter.marshalExtensions(list);
 
         // then
         String wrappedXmlResult = String.format(WRAPPED_FORMAT, xmlResult);
@@ -65,13 +71,28 @@ public class ExtensionUtilsTest {
         assertThat(wrappedXmlResult, CompareMatcher.isIdenticalTo(wrappedInputDoc));
     }
 
+    @Test
+    public void testUtf8Handling() throws JAXBException, XMLStreamException, UnsupportedEncodingException {
+        // given
+        ExtensionType extension = new ExtensionType();
+        extension.setExtensionName(UTF8_SEQUENCE);
+        List<ExtensionType> extensions = Arrays.asList(extension);
+
+        //when
+        String extensionsXml = ExtensionConverter.marshalExtensions(extensions);
+        List<ExtensionType> resultExtensions = ExtensionConverter.unmarshalExtensions(extensionsXml);
+
+        //then
+        assertEquals(UTF8_SEQUENCE, resultExtensions.get(0).getExtensionName());
+    }
+
     @Test
     public void testUnmarshal() throws IOException, JAXBException {
         // given
         String inputDoc = XmlTestUtils.loadDocumentAsString(RES_PATH + "extensionMarshal.xml");
 
         // when
-        List<ExtensionType> extensions = ExtensionUtils.unmarshalExtensions(inputDoc);
+        List<ExtensionType> extensions = ExtensionConverter.unmarshalExtensions(inputDoc);
 
         // then
         checkExtensions(extensions, 1);
@@ -83,7 +104,7 @@ public class ExtensionUtilsTest {
         String inputDoc = XmlTestUtils.loadDocumentAsString(RES_PATH + "extensionMarshalMore.xml");
 
         // when
-        List<ExtensionType> extensions = ExtensionUtils.unmarshalExtensions(inputDoc);
+        List<ExtensionType> extensions = ExtensionConverter.unmarshalExtensions(inputDoc);
 
         // then
         checkExtensions(extensions, 2);
diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverterTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverterTest.java
index 77838eda5..14860912c 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverterTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverterTest.java
@@ -14,7 +14,7 @@
 package eu.europa.ec.edelivery.smp.conversion;
 
 import eu.europa.ec.edelivery.smp.exceptions.XmlParsingException;
-import eu.europa.ec.cipa.smp.server.util.XmlTestUtils;
+import eu.europa.ec.edelivery.smp.testutil.XmlTestUtils;
 import org.junit.Test;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ServiceGroup;
 import org.xml.sax.SAXParseException;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverterTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverterTest.java
index a21a98bac..ea799e42a 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverterTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverterTest.java
@@ -14,7 +14,7 @@
 package eu.europa.ec.edelivery.smp.conversion;
 
 import eu.europa.ec.edelivery.smp.exceptions.XmlParsingException;
-import eu.europa.ec.cipa.smp.server.util.XmlTestUtils;
+import eu.europa.ec.edelivery.smp.testutil.XmlTestUtils;
 import org.junit.Test;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.RedirectType;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ServiceEndpointList;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceGroupServiceIntegrationTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceGroupServiceIntegrationTest.java
index 82ca80b6e..589253981 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceGroupServiceIntegrationTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceGroupServiceIntegrationTest.java
@@ -41,8 +41,8 @@ import java.util.List;
 
 import static eu.europa.ec.edelivery.smp.conversion.ServiceGroupConverter.toDbModel;
 import static eu.europa.ec.edelivery.smp.conversion.ServiceGroupConverter.unmarshal;
-import static eu.europa.ec.cipa.smp.server.util.XmlTestUtils.loadDocumentAsString;
-import static eu.europa.ec.cipa.smp.server.util.XmlTestUtils.marshall;
+import static eu.europa.ec.edelivery.smp.testutil.XmlTestUtils.loadDocumentAsString;
+import static eu.europa.ec.edelivery.smp.testutil.XmlTestUtils.marshall;
 import static eu.europa.ec.smp.api.Identifiers.asParticipantId;
 import static org.junit.Assert.*;
 
diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataIntegrationTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataIntegrationTest.java
index 5e38292f4..6574b16d2 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataIntegrationTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataIntegrationTest.java
@@ -40,8 +40,8 @@ import java.io.IOException;
 import java.util.List;
 
 import static eu.europa.ec.edelivery.smp.conversion.ServiceMetadataConverter.unmarshal;
-import static eu.europa.ec.cipa.smp.server.util.XmlTestUtils.loadDocumentAsString;
-import static eu.europa.ec.cipa.smp.server.util.XmlTestUtils.marshall;
+import static eu.europa.ec.edelivery.smp.testutil.XmlTestUtils.loadDocumentAsString;
+import static eu.europa.ec.edelivery.smp.testutil.XmlTestUtils.marshall;
 import static eu.europa.ec.smp.api.Identifiers.asDocumentId;
 import static eu.europa.ec.smp.api.Identifiers.asParticipantId;
 import static org.junit.Assert.*;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataSignerTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataSignerTest.java
index 130f171f1..d836da941 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataSignerTest.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ServiceMetadataSignerTest.java
@@ -13,22 +13,17 @@
 
 package eu.europa.ec.edelivery.smp.services;
 
-import eu.europa.ec.cipa.smp.server.security.SignatureUtil;
-import eu.europa.ec.edelivery.smp.config.PropertiesTestConfig;
+import eu.europa.ec.edelivery.smp.testutil.SignatureUtil;
 import eu.europa.ec.edelivery.smp.config.SmpServicesTestConfig;
-import eu.europa.ec.edelivery.smp.services.ServiceMetadataSigner;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import static eu.europa.ec.cipa.smp.server.util.XmlTestUtils.loadDocument;
+import static eu.europa.ec.edelivery.smp.testutil.XmlTestUtils.loadDocument;
 
 /**
  * Created by rodrfla on 20/02/2017.
diff --git a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/SignatureUtil.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/SignatureUtil.java
similarity index 97%
rename from smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/SignatureUtil.java
rename to smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/SignatureUtil.java
index b3e40e321..5f462b7fb 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/SignatureUtil.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/SignatureUtil.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,9 +11,8 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.security;
+package eu.europa.ec.edelivery.smp.testutil;
 
-import eu.europa.ec.cipa.smp.server.util.XmlTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/X509KeySelector.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/X509KeySelector.java
similarity index 91%
rename from smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/X509KeySelector.java
rename to smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/X509KeySelector.java
index 8965ee6bb..c39464956 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/security/X509KeySelector.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/X509KeySelector.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,7 +11,7 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.security;
+package eu.europa.ec.edelivery.smp.testutil;
 
 import javax.xml.crypto.*;
 import javax.xml.crypto.dsig.SignatureMethod;
diff --git a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/XmlTestUtils.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/XmlTestUtils.java
similarity index 91%
rename from smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/XmlTestUtils.java
rename to smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/XmlTestUtils.java
index 817fd8095..7201c7729 100644
--- a/smp-server-library/src/test/java/eu/europa/ec/cipa/smp/server/util/XmlTestUtils.java
+++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/XmlTestUtils.java
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017 European Commission | CEF eDelivery
+ * Copyright 2018 European Commission | CEF eDelivery
  *
- * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  * You may not use this work except in compliance with the Licence.
  *
  * You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
@@ -11,9 +11,8 @@
  * See the Licence for the specific language governing permissions and limitations under the Licence.
  */
 
-package eu.europa.ec.cipa.smp.server.util;
+package eu.europa.ec.edelivery.smp.testutil;
 
-import eu.europa.ec.cipa.smp.server.security.SignatureUtil;
 import org.apache.commons.io.IOUtils;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ServiceGroup;
 import org.oasis_open.docs.bdxr.ns.smp._2016._05.ServiceMetadata;
-- 
GitLab