aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java')
-rw-r--r--id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java108
1 files changed, 108 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java
new file mode 100644
index 000000000..b7ce1769f
--- /dev/null
+++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/VerifyXMLSignatureRequestBuilderTest.java
@@ -0,0 +1,108 @@
+/*
+* Copyright 2003 Federal Chancellery Austria
+*
+* 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 test.at.gv.egovernment.moa.id.auth.builder;
+
+import java.io.FileInputStream;
+import java.io.RandomAccessFile;
+
+import org.w3c.dom.Element;
+import test.at.gv.egovernment.moa.id.auth.invoke.MOASPSSTestCase;
+
+import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder;
+import at.gv.egovernment.moa.id.auth.data.CreateXMLSignatureResponse;
+import at.gv.egovernment.moa.id.auth.data.IdentityLink;
+import at.gv.egovernment.moa.id.auth.parser.CreateXMLSignatureResponseParser;
+import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser;
+import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker;
+import at.gv.egovernment.moa.id.config.ConfigurationProvider;
+import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider;
+
+
+
+/**
+ * Test case for the signature verification web service.
+ *
+ * This test requires a running SignatureVerification web service.
+ *
+ * @author Stefan Knirsch
+ * @version $Id$
+ */
+public class VerifyXMLSignatureRequestBuilderTest extends MOASPSSTestCase {
+
+
+ private SignatureVerificationInvoker caller;
+
+ public VerifyXMLSignatureRequestBuilderTest(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+ System.setProperty(
+ ConfigurationProvider.CONFIG_PROPERTY_NAME,
+ "data/test/conf/ConfigurationTest.xml");
+ caller = new SignatureVerificationInvoker();
+ }
+
+ public void testVerifyXMLSignatureRequestBuilderIdentityLink() throws Exception {
+
+ RandomAccessFile infoBox = new RandomAccessFile(
+ "data/test/xmldata/testperson1/InfoboxReadResponse.xml","r");
+ byte[] b = new byte[(int) infoBox.length()];
+ infoBox.read(b);
+ infoBox.close();
+ String xmlInfoboxReadResponse = new String(b, "UTF-8");
+
+
+ RandomAccessFile vr = new RandomAccessFile(
+ "data/test/xmldata/standard/VerifyXMLSignatureRequestIdentityLink.xml","r");
+ b = new byte[(int) vr.length()];
+ vr.read(b);
+ vr.close();
+ String xmlResponse = new String(b, "UTF-8");
+
+ InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(xmlInfoboxReadResponse);
+ IdentityLink idl = irrp.parseIdentityLink();
+ VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder();
+ AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance();
+
+ Element requestBuild = vsrb.build(idl, authConf.getMoaSpIdentityLinkTrustProfileID());
+
+ assertXmlEquals(requestBuild, xmlResponse);
+
+ }
+
+ public void testVerifyXMLSignature2() throws Exception {
+
+ RandomAccessFile s = new RandomAccessFile("data/test/xmldata/standard/CreateXMLSignatureResponse.xml","r");
+ byte[] b = new byte[(int) s.length()];
+ s.read(b);
+ s.close();
+ String xmlCreateXMLSignatureResponse = new String(b, "UTF-8");
+
+ CreateXMLSignatureResponseParser cXMLsrp = new CreateXMLSignatureResponseParser(xmlCreateXMLSignatureResponse);
+ CreateXMLSignatureResponse csr = cXMLsrp.parseResponse();
+
+ VerifyXMLSignatureRequestBuilder vsrb = new VerifyXMLSignatureRequestBuilder();
+
+ AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance();
+
+ Element request = vsrb.build(csr, authConf.getMoaSpAuthBlockVerifyTransformsInfoIDs(), authConf.getMoaSpIdentityLinkTrustProfileID());
+
+ // check the result
+ assertXmlEquals(request, new FileInputStream("data/test/xmldata/standard/VerifyXMLSignatureRequestCreateXML.xml"));
+
+ }
+ }