From ebede55b888e8232cef37a2f4b40dbb0746dd28a Mon Sep 17 00:00:00 2001 From: mcentner Date: Mon, 30 Nov 2009 15:05:21 +0000 Subject: Added test classes for creating a signature with MOCCA and sending it to MOA-SP for verification. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@557 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- bkucommon/src/test/java/moaspss/MOASPSSTest.java | 119 ----------------------- 1 file changed, 119 deletions(-) delete mode 100644 bkucommon/src/test/java/moaspss/MOASPSSTest.java (limited to 'bkucommon/src/test/java/moaspss/MOASPSSTest.java') diff --git a/bkucommon/src/test/java/moaspss/MOASPSSTest.java b/bkucommon/src/test/java/moaspss/MOASPSSTest.java deleted file mode 100644 index 21d42176..00000000 --- a/bkucommon/src/test/java/moaspss/MOASPSSTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed 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 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package moaspss; - -import static org.junit.Assert.assertNotNull; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.namespace.QName; - -import moaspss.generated.ContentOptionalRefType; -import moaspss.generated.InputDataType; -import moaspss.generated.MOAFault; -import moaspss.generated.ObjectFactory; -import moaspss.generated.SignatureVerificationPortType; -import moaspss.generated.SignatureVerificationService; -import moaspss.generated.VerifyXMLSignatureRequestType; -import moaspss.generated.VerifyXMLSignatureResponseType; -import moaspss.generated.VerifyXMLSignatureRequestType.VerifySignatureInfo; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore -public class MOASPSSTest { - - public static final String REQ_FILE = "TODO.xml"; - private static JAXBContext ctx; - private static SignatureVerificationPortType port; - - @BeforeClass - public static void setUp() throws JAXBException, MalformedURLException { - QName serviceName = new QName("http://reference.e-government.gv.at/namespace/moa/wsdl/20020822#", "SignatureVerificationService"); - - URL wsdlURL = MOASPSSTest.class.getClassLoader().getResource("MOA-SPSS-1.3.wsdl"); - - assertNotNull(wsdlURL); - - SignatureVerificationService service = new SignatureVerificationService(wsdlURL, serviceName); - - port = service.getSignatureVerificationPort(); - assertNotNull(port); - ctx = JAXBContext.newInstance(VerifyXMLSignatureRequestType.class.getPackage().getName()); - } - - @Test - public void verifySignature() throws JAXBException, IOException { - - InputStream stream = MOASPSSTest.class.getClassLoader().getResourceAsStream("Untitled1.xml"); - assertNotNull(stream); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - int b; - while ((b = stream.read()) != -1) { - bos.write(b); - } - stream.close(); - - ObjectFactory factory = new ObjectFactory(); - - ContentOptionalRefType contentOptionalRefType = factory.createContentOptionalRefType(); - contentOptionalRefType.setBase64Content(bos.toByteArray()); - - VerifySignatureInfo verifySignatureInfo = factory.createVerifyXMLSignatureRequestTypeVerifySignatureInfo(); - verifySignatureInfo.setVerifySignatureEnvironment(contentOptionalRefType); - verifySignatureInfo.setVerifySignatureLocation("/child::*[1]/child::*[2]"); - - VerifyXMLSignatureRequestType verifyXMLSignatureRequestType = factory.createVerifyXMLSignatureRequestType(); - verifyXMLSignatureRequestType.setVerifySignatureInfo(verifySignatureInfo); - verifyXMLSignatureRequestType.setTrustProfileID("IdentityLink"); - verifyXMLSignatureRequestType.setReturnHashInputData(Boolean.TRUE); - - VerifyXMLSignatureResponseType resp = null; - try { - resp = port.verifyXMLSignature(verifyXMLSignatureRequestType); - } catch (MOAFault e) { - e.printStackTrace(); - } - - JAXBElement verifyXMLSignatureResponse = factory.createVerifyXMLSignatureResponse(resp); - - Marshaller marshaller = ctx.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - marshaller.marshal(verifyXMLSignatureResponse, System.out); - - List hashInputData = resp.getHashInputData(); - for (InputDataType inputDataType : hashInputData) { - System.out.println("------------------------------------------"); - System.out.println("HashInputData: " + inputDataType.getPartOf() + " " + inputDataType.getReferringSigReference()); - System.out.println("------------------------------------------"); - System.out.write(inputDataType.getBase64Content()); - System.out.println(); - } - } -} -- cgit v1.2.3