aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java')
-rw-r--r--id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java129
1 files changed, 129 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java
new file mode 100644
index 000000000..87ddaef0c
--- /dev/null
+++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/CreateXMLSignatureBuilderTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 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 at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.id.auth.builder;
+
+import at.gv.egovernment.moa.id.auth.builder.CreateXMLSignatureRequestBuilder;
+
+import test.at.gv.egovernment.moa.id.UnitTestCase;
+
+/**
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class CreateXMLSignatureBuilderTest extends UnitTestCase {
+ private static final String nl = "\n";
+ public static final String TRANSFORMS_INFO =
+ " <sl10:TransformsInfo>" + nl +
+ " <dsig:Transforms>" + nl +
+ " <dsig:Transform Algorithm='http://www.w3.org/2000/09/xmldsig#enveloped-signature'/>" + nl +
+ " <dsig:Transform Algorithm='http://www.w3.org/TR/1999/REC-xslt-19991116'>" + nl +
+"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' >" + nl +
+"<xsl:template match='/'>" + nl +
+"<html>" + nl +
+"<body>" + nl +
+"</body>" + nl +
+"</html>" + nl +
+"</xsl:template>" + nl +
+"</xsl:stylesheet>" + nl +
+ " </dsig:Transform>" + nl +
+ " </dsig:Transforms>" + nl +
+ " <sl10:FinalDataMetaInfo>" + nl +
+ " <sl10:MimeType>text/html</sl10:MimeType>" + nl +
+ " </sl10:FinalDataMetaInfo>" + nl +
+ " </sl10:TransformsInfo>" + nl;
+ public static final String REQUEST_SHOULD =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + nl +
+"<sl11:CreateXMLSignatureRequest xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\" xmlns:sl11=\"http://www.buergerkarte.at/namespaces/securitylayer/20020831#\">" + nl +
+" <sl11:KeyboxIdentifier>SecureSignatureKeypair</sl11:KeyboxIdentifier>" + nl +
+" <sl11:DataObjectInfo Structure=\"detached\">" + nl +
+" <sl10:DataObject Reference=\"\"/>" + nl +
+TRANSFORMS_INFO +
+" </sl11:DataObjectInfo>" + nl +
+" <sl11:SignatureInfo>" + nl +
+" <sl11:SignatureEnvironment>" + nl +
+" <sl10:XMLContent>" + AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD + "</sl10:XMLContent>" + nl +
+" </sl11:SignatureEnvironment>" + nl +
+" <sl11:SignatureLocation Index=\"2\">/saml:Assertion</sl11:SignatureLocation>" + nl +
+" </sl11:SignatureInfo>" + nl +
+"</sl11:CreateXMLSignatureRequest>";
+
+
+ public static final String TRANSFORMS_INFO_SL12 =
+ " <sl:TransformsInfo>" + nl +
+ " <dsig:Transforms>" + nl +
+ " <dsig:Transform Algorithm='http://www.w3.org/2000/09/xmldsig#enveloped-signature'/>" + nl +
+ " <dsig:Transform Algorithm='http://www.w3.org/TR/1999/REC-xslt-19991116'>" + nl +
+"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' >" + nl +
+"<xsl:template match='/'>" + nl +
+"<html>" + nl +
+"<body>" + nl +
+"</body>" + nl +
+"</html>" + nl +
+"</xsl:template>" + nl +
+"</xsl:stylesheet>" + nl +
+ " </dsig:Transform>" + nl +
+ " </dsig:Transforms>" + nl +
+ " <sl:FinalDataMetaInfo>" + nl +
+ " <sl:MimeType>text/html</sl:MimeType>" + nl +
+ " </sl:FinalDataMetaInfo>" + nl +
+ " </sl:TransformsInfo>" + nl;
+ public static final String REQUEST_SHOULD_SL12 =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + nl +
+"<sl:CreateXMLSignatureRequest xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:sl=\"http://www.buergerkarte.at/namespaces/securitylayer/1.2#\">" + nl +
+" <sl:KeyboxIdentifier>SecureSignatureKeypair</sl:KeyboxIdentifier>" + nl +
+" <sl:DataObjectInfo Structure=\"detached\">" + nl +
+" <sl:DataObject Reference=\"\"/>" + nl +
+TRANSFORMS_INFO_SL12 +
+" </sl:DataObjectInfo>" + nl +
+" <sl:SignatureInfo>" + nl +
+" <sl:SignatureEnvironment>" + nl +
+" <sl:XMLContent>" + AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD + "</sl:XMLContent>" + nl +
+" </sl:SignatureEnvironment>" + nl +
+" <sl:SignatureLocation Index=\"2\">/saml:Assertion</sl:SignatureLocation>" + nl +
+" </sl:SignatureInfo>" + nl +
+"</sl:CreateXMLSignatureRequest>";
+
+
+
+
+ public CreateXMLSignatureBuilderTest(String name) {
+ super(name);
+ }
+
+ public void testBuild() throws Exception {
+ // test build for Security Layer version 1.1 and 1.0
+ String request = new CreateXMLSignatureRequestBuilder().build(
+ AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD, "SecureSignatureKeypair",
+ new String[] {TRANSFORMS_INFO},
+ false);
+ assertXmlEquals(REQUEST_SHOULD, request);
+ // test build for Security Layer version 1.2
+ String requestSL12 = new CreateXMLSignatureRequestBuilder().build(
+ AuthenticationBlockAssertionBuilderTest.ASSERTION_SHOULD, "SecureSignatureKeypair",
+ new String[] {TRANSFORMS_INFO},
+ true);
+ assertXmlEquals(REQUEST_SHOULD_SL12, requestSL12);
+ }
+}