diff options
Diffstat (limited to 'id')
31 files changed, 3726 insertions, 3730 deletions
diff --git a/id/server/idserverlib/pom.xml b/id/server/idserverlib/pom.xml index d66159744..69e1c8c18 100644 --- a/id/server/idserverlib/pom.xml +++ b/id/server/idserverlib/pom.xml @@ -113,6 +113,11 @@ <groupId>iaik.prod</groupId>
<artifactId>iaik_X509TrustManager</artifactId>
</dependency>
+<!-- <dependency>
+ <groupId>iaik</groupId>
+ <artifactId>moa</artifactId>
+ <version>1.28</version>
+ </dependency> -->
<dependency>
<groupId>edu.internet2.middleware</groupId>
<artifactId>shibboleth-common</artifactId>
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/SSOSendAssertionServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/SSOSendAssertionServlet.java index 9b559770f..8dd547bb5 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/SSOSendAssertionServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/SSOSendAssertionServlet.java @@ -1,7 +1,5 @@ package at.gv.egovernment.moa.id.auth.servlet; -import iaik.util.logging.Log; - import java.io.IOException; import java.io.PrintWriter; @@ -87,7 +85,7 @@ public class SSOSendAssertionServlet extends AuthServlet{ String correspondingMOASession = ssomanager.existsOldSSOSession(ssoId); if (correspondingMOASession != null) { - Log.warn("Request sends an old SSO Session ID("+ssoId+")! " + + Logger.warn("Request sends an old SSO Session ID("+ssoId+")! " + "Invalidate the corresponding MOASession with ID="+ correspondingMOASession); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java index 55a20d558..bc53a876c 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java @@ -25,7 +25,6 @@ package at.gv.egovernment.moa.id.config.auth; import iaik.security.cipher.AESKeyGenerator; -import iaik.util.logging.Log; import java.io.File; import java.io.FileInputStream; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/legacy/BuildFromLegacyConfig.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/legacy/BuildFromLegacyConfig.java index 1460668e2..96d0bd2ed 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/legacy/BuildFromLegacyConfig.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/legacy/BuildFromLegacyConfig.java @@ -1,6 +1,5 @@ package at.gv.egovernment.moa.id.config.legacy; -import iaik.util.logging.Log; import iaik.x509.X509Certificate; import java.io.BufferedInputStream; @@ -76,6 +75,7 @@ import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.data.IssuerAndSerial; import at.gv.egovernment.moa.id.protocols.pvp2x.utils.SAML2Utils; +import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.Base64Utils; import at.gv.egovernment.moa.util.DOMUtils; import at.gv.egovernment.moa.util.MiscUtil; @@ -93,7 +93,7 @@ public class BuildFromLegacyConfig { Element configElem; ConfigurationBuilder builder; - Log.info("Load Legacy-Configuration from file=" + fileName); + Logger.info("Load Legacy-Configuration from file=" + fileName); try { // load the main config file diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java index 39f5479ce..6a3f4cc9e 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java @@ -3,8 +3,6 @@ */
package at.gv.egovernment.moa.id.config.stork;
-import iaik.util.logging.Log;
-
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -94,13 +92,13 @@ public class STORKConfig { SAMLSigningParameter samlsign = stork.getSAMLSigningParameter();
if (samlsign == null) {
- Log.warn("Error in MOA-ID Configuration. No STORK->SAMLSigningParameter configuration found.");
+ Logger.warn("Error in MOA-ID Configuration. No STORK->SAMLSigningParameter configuration found.");
} else {
SignatureVerificationParameterType sigverify = samlsign.getSignatureVerificationParameter();
if (sigverify == null) {
- Log.warn("Error in MOA-ID Configuration. No STORK->SignatureVerificationParameter configuration found.");
+ Logger.warn("Error in MOA-ID Configuration. No STORK->SignatureVerificationParameter configuration found.");
} else {
sigverifyparam = new SignatureVerificationParameter(sigverify.getTrustProfileID());
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java index 604077844..d587092eb 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java @@ -1,6 +1,6 @@ package at.gv.egovernment.moa.id.entrypoints; -import iaik.util.logging.Log; + import java.io.IOException; import java.util.ConcurrentModificationException; @@ -336,7 +336,7 @@ public class DispatcherServlet extends AuthServlet{ String correspondingMOASession = ssomanager.existsOldSSOSession(ssoId); if (correspondingMOASession != null) { - Log.warn("Request sends an old SSO Session ID("+ssoId+")! " + + Logger.warn("Request sends an old SSO Session ID("+ssoId+")! " + "Invalidate the corresponding MOASession with ID="+ correspondingMOASession); AuthenticationSessionStoreage.destroySession(correspondingMOASession); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java index b01a6a36e..ba4f65571 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java @@ -1,7 +1,5 @@ package at.gv.egovernment.moa.id.storage; -import iaik.util.logging.Log; - import java.io.Serializable; import java.util.Date; import java.util.List; @@ -53,7 +51,7 @@ public class AssertionStorage { //store AssertionStore element to Database try { MOASessionDBUtils.saveOrUpdate(element); - Log.info("Assertion with Artifact=" + artifact + " is stored in Database"); + Logger.info("Assertion with Artifact=" + artifact + " is stored in Database"); } catch (MOADatabaseException e) { Logger.warn("Assertion could not be stored."); @@ -76,7 +74,7 @@ public class AssertionStorage { return test; } catch (Exception e) { - Log.warn("Assertion Cast-Exception by using Artifact=" + artifact); + Logger.warn("Assertion Cast-Exception by using Artifact=" + artifact); throw new MOADatabaseException("Assertion Cast-Exception"); } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java index 498188ffe..5da3dd8f6 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java @@ -1,7 +1,5 @@ package at.gv.egovernment.moa.id.storage; -import iaik.util.logging.Log; - import java.io.Serializable; import java.util.Date; import java.util.HashMap; @@ -79,7 +77,7 @@ public class AuthenticationSessionStoreage { //store AssertionStore element to Database try { MOASessionDBUtils.saveOrUpdate(dbsession); - Log.info("MOASession with sessionID=" + id + " is stored in Database"); + Logger.info("MOASession with sessionID=" + id + " is stored in Database"); } catch (MOADatabaseException e) { Logger.warn("MOASession could not be created."); @@ -102,7 +100,7 @@ public class AuthenticationSessionStoreage { dbsession.setUpdated(new Date()); MOASessionDBUtils.saveOrUpdate(dbsession); - Log.info("MOASession with sessionID=" + session.getSessionID() + " is stored in Database"); + Logger.info("MOASession with sessionID=" + session.getSessionID() + " is stored in Database"); } catch (MOADatabaseException e) { Logger.warn("MOASession could not be stored."); @@ -125,7 +123,7 @@ public class AuthenticationSessionStoreage { dbsession.setUpdated(new Date()); MOASessionDBUtils.saveOrUpdate(dbsession); - Log.info("MOASession with sessionID=" + session.getSessionID() + " is stored in Database"); + Logger.info("MOASession with sessionID=" + session.getSessionID() + " is stored in Database"); } catch (MOADatabaseException e) { Logger.warn("MOASession could not be stored."); @@ -295,7 +293,7 @@ public class AuthenticationSessionStoreage { throw new MOADatabaseException("No MOA Session with id: " + sessionID); } catch (Throwable e) { - Log.warn("MOASession deserialization-exception by using MOASessionID=" + sessionID); + Logger.warn("MOASession deserialization-exception by using MOASessionID=" + sessionID); throw new MOADatabaseException("MOASession deserialization-exception"); } } diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test100StartAuthentication.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test100StartAuthentication.java index 818773794..f875ea809 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test100StartAuthentication.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test100StartAuthentication.java @@ -1,200 +1,200 @@ -/* - * 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.abnahme.A; - -import test.abnahme.AbnahmeTestCase; -import at.gv.egovernment.moa.id.AuthenticationException; -import at.gv.egovernment.moa.id.auth.WrongParametersException; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ -public class Test100StartAuthentication extends AbnahmeTestCase { - - public Test100StartAuthentication(String name) { - super(name); - } - - public void testA101() throws Exception { - try { - String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL - "gb", //target - null, - "http://localhost:9080/", //oaURL - "file:" + findXmldata("AuthTemplate.html"), - "http://localhost:3495/http-security-layer-request", - null, null, null, null); - htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); - //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); - assertEquals(readXmldata("htmlForm.html"),htmlForm); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA102() throws Exception { - try { - String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL - "gb", //target - null, - "http://localhost:9080/", //oaURL - null, - "http://localhost:3495/http-security-layer-request", null, null, null, null); - htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); - //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); - assertEquals(readXmldata("htmlForm.html"),htmlForm); - - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA103() throws Exception { - try { - String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL - "gb", //target - null, - "http://localhost:9080/", //oaURL - "file:" + findXmldata("AuthTemplate.html"), - null, - null, - null, null, null); - htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); - //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); - assertEquals(readXmldata("htmlForm.html"),htmlForm); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA151() throws Exception { - try { - try { - server.startAuthentication(null, //authURL - "gb", //target - null, - "http://localhost:9080/", //oaURL - null, null, null, null, null, null); - //assertEquals("",htmlForm); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (WrongParametersException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA152() throws Exception { - try { - try { - server.startAuthentication("http://localhost:8080/auth", //authURL - "gb", null, "http://localhost:9080/", //oaURL - null, null, null, null, null, null); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA153() throws Exception { - try { - try { - server.startAuthentication("https://localhost:8443/auth", //authURL - "gb", null, "http://host_not_in_config/", //oaURL - null, null, null, null, null, null); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA154() throws Exception { - try { - try { - server.startAuthentication("https://localhost:8443/auth", //authURL - "gb", null, null, //oaURL - null, null, null, null, null, null); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (WrongParametersException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA155() throws Exception { - try { - try { - server.startAuthentication("https://localhost:8443/auth", //authURL - null, null, "http://localhost:9080/", //oaURL - null, null, null, null, null, null); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (WrongParametersException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - //assertEquals("",htmlForm); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - -} +///* +// * 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.abnahme.A; +// +//import test.abnahme.AbnahmeTestCase; +//import at.gv.egovernment.moa.id.AuthenticationException; +//import at.gv.egovernment.moa.id.auth.WrongParametersException; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ +//public class Test100StartAuthentication extends AbnahmeTestCase { +// +// public Test100StartAuthentication(String name) { +// super(name); +// } +// +// public void testA101() throws Exception { +// try { +// String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL +// "gb", //target +// null, +// "http://localhost:9080/", //oaURL +// "file:" + findXmldata("AuthTemplate.html"), +// "http://localhost:3495/http-security-layer-request", +// null, null, null, null); +// htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); +// //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); +// assertEquals(readXmldata("htmlForm.html"),htmlForm); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA102() throws Exception { +// try { +// String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL +// "gb", //target +// null, +// "http://localhost:9080/", //oaURL +// null, +// "http://localhost:3495/http-security-layer-request", null, null, null, null); +// htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); +// //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); +// assertEquals(readXmldata("htmlForm.html"),htmlForm); +// +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA103() throws Exception { +// try { +// String htmlForm = server.startAuthentication("https://localhost:8443/auth", //authURL +// "gb", //target +// null, +// "http://localhost:9080/", //oaURL +// "file:" + findXmldata("AuthTemplate.html"), +// null, +// null, +// null, null, null); +// htmlForm = killExclusive(htmlForm, "MOASessionID=","\"","DELETED"); +// //writeXmldata("htmlForm_out.html",htmlForm.getBytes("UTF-8")); +// assertEquals(readXmldata("htmlForm.html"),htmlForm); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA151() throws Exception { +// try { +// try { +// server.startAuthentication(null, //authURL +// "gb", //target +// null, +// "http://localhost:9080/", //oaURL +// null, null, null, null, null, null); +// //assertEquals("",htmlForm); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (WrongParametersException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA152() throws Exception { +// try { +// try { +// server.startAuthentication("http://localhost:8080/auth", //authURL +// "gb", null, "http://localhost:9080/", //oaURL +// null, null, null, null, null, null); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA153() throws Exception { +// try { +// try { +// server.startAuthentication("https://localhost:8443/auth", //authURL +// "gb", null, "http://host_not_in_config/", //oaURL +// null, null, null, null, null, null); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA154() throws Exception { +// try { +// try { +// server.startAuthentication("https://localhost:8443/auth", //authURL +// "gb", null, null, //oaURL +// null, null, null, null, null, null); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (WrongParametersException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA155() throws Exception { +// try { +// try { +// server.startAuthentication("https://localhost:8443/auth", //authURL +// null, null, "http://localhost:9080/", //oaURL +// null, null, null, null, null, null); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (WrongParametersException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// //assertEquals("",htmlForm); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test200VerifyIdentityLink.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test200VerifyIdentityLink.java index 9a6058370..2d00458e5 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test200VerifyIdentityLink.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test200VerifyIdentityLink.java @@ -1,393 +1,393 @@ -/* - * 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.abnahme.A; - -import java.util.HashMap; -import java.util.Vector; - -import org.w3c.dom.Element; - -import test.abnahme.AbnahmeTestCase; -import at.gv.egovernment.moa.id.AuthenticationException; -import at.gv.egovernment.moa.id.ParseException; -import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; -import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; -import at.gv.egovernment.moa.id.auth.parser.VerifyXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.validator.ValidateException; -import at.gv.egovernment.moa.id.auth.validator.VerifyXMLSignatureResponseValidator; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ -public class Test200VerifyIdentityLink extends AbnahmeTestCase { - - public Test200VerifyIdentityLink(String name) { - super(name); - } - - public void testA201() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, parameters); - - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - - VerifyXMLSignatureResponseParser respParser = new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames(), VerifyXMLSignatureResponseValidator.CHECK_IDENTITY_LINK, true); - - /* - * HINWEIS: clearSamlAssertion löscht aus einer beliebiegen String-Repräsentation einer XML-Struktur - * AUSSLIESSLICH die Attribute IssueInstand und die AssertionID heraus, von dem her ist diese - * Method hier verwendbar - */ - - assertXmlEquals(clearSamlAssertion(readXmldata("CreateXMLSignatureRequest.xml")), clearSamlAssertion(createXMLSignatureRequest)); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - - } - public void testA251() throws Exception { - try { - startAuthentication(); - String sessionID = "0"; - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA252() throws Exception { - try { - String sessionID = startAuthentication(); - - server.setSecondsSessionTimeOut(-100); - server.cleanup(); - server.setSecondsSessionTimeOut(1000); - - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA253() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA254() throws Exception { - try { - String sessionID = startAuthentication(); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA255() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - } - catch (ParseException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA256() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA257() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA258() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA259() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA260() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA261() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA262() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - new InfoboxReadResponseParser(infoboxReadResponse).parseIdentityLink(); - // System.out.println(infoboxReadResponse); - - try { - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA263() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - - VerifyXMLSignatureResponseParser respParser = new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - - // String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, infoboxReadResponse); - // System.out.println(createXMLSignatureRequest); - // String createXMLSignatureResponse = readFile(TESTDATA_ROOT + "xmldata/standard/"+"CreateXMLSignatureResponse.xml"); - // String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - Vector identityLinkSigners = new Vector(); - identityLinkSigners.add("CN=TEST,OU=TEST,O=TEST,C=AT"); - try { - VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), identityLinkSigners, VerifyXMLSignatureResponseValidator.CHECK_IDENTITY_LINK, true); - System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); - fail(this.getName() + " hat KEINE FEHLER geworfen"); - } - catch (ValidateException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } -} +///* +// * 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.abnahme.A; +// +//import java.util.HashMap; +//import java.util.Vector; +// +//import org.w3c.dom.Element; +// +//import test.abnahme.AbnahmeTestCase; +//import at.gv.egovernment.moa.id.AuthenticationException; +//import at.gv.egovernment.moa.id.ParseException; +//import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; +//import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; +//import at.gv.egovernment.moa.id.auth.data.IdentityLink; +//import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; +//import at.gv.egovernment.moa.id.auth.parser.InfoboxReadResponseParser; +//import at.gv.egovernment.moa.id.auth.parser.VerifyXMLSignatureResponseParser; +//import at.gv.egovernment.moa.id.auth.validator.ValidateException; +//import at.gv.egovernment.moa.id.auth.validator.VerifyXMLSignatureResponseValidator; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ +//public class Test200VerifyIdentityLink extends AbnahmeTestCase { +// +// public Test200VerifyIdentityLink(String name) { +// super(name); +// } +// +// public void testA201() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, parameters); +// +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// +// VerifyXMLSignatureResponseParser respParser = new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames(), VerifyXMLSignatureResponseValidator.CHECK_IDENTITY_LINK, true); +// +// /* +// * HINWEIS: clearSamlAssertion l�scht aus einer beliebiegen String-Repr�sentation einer XML-Struktur +// * AUSSLIESSLICH die Attribute IssueInstand und die AssertionID heraus, von dem her ist diese +// * Method hier verwendbar +// */ +// +// assertXmlEquals(clearSamlAssertion(readXmldata("CreateXMLSignatureRequest.xml")), clearSamlAssertion(createXMLSignatureRequest)); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// +// } +// public void testA251() throws Exception { +// try { +// startAuthentication(); +// String sessionID = "0"; +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA252() throws Exception { +// try { +// String sessionID = startAuthentication(); +// +// server.setSecondsSessionTimeOut(-100); +// server.cleanup(); +// server.setSecondsSessionTimeOut(1000); +// +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA253() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA254() throws Exception { +// try { +// String sessionID = startAuthentication(); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA255() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// } +// catch (ParseException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA256() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA257() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA258() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA259() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA260() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA261() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA262() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// new InfoboxReadResponseParser(infoboxReadResponse).parseIdentityLink(); +// // System.out.println(infoboxReadResponse); +// +// try { +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA263() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// +// VerifyXMLSignatureResponseParser respParser = new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// +// // String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, infoboxReadResponse); +// // System.out.println(createXMLSignatureRequest); +// // String createXMLSignatureResponse = readFile(TESTDATA_ROOT + "xmldata/standard/"+"CreateXMLSignatureResponse.xml"); +// // String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// Vector identityLinkSigners = new Vector(); +// identityLinkSigners.add("CN=TEST,OU=TEST,O=TEST,C=AT"); +// try { +// VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), identityLinkSigners, VerifyXMLSignatureResponseValidator.CHECK_IDENTITY_LINK, true); +// System.err.println(this.getName() + " hat KEINE FEHLER geworfen"); +// fail(this.getName() + " hat KEINE FEHLER geworfen"); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test300VerifyAuthBlock.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test300VerifyAuthBlock.java index 6e6092b3f..9d07b6620 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test300VerifyAuthBlock.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test300VerifyAuthBlock.java @@ -1,633 +1,633 @@ -/* - * 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.abnahme.A; - -import java.util.Calendar; -import java.util.HashMap; - -import org.w3c.dom.Element; -import test.abnahme.AbnahmeTestCase; - -import at.gv.egovernment.moa.id.AuthenticationException; -import at.gv.egovernment.moa.id.BuildException; -import at.gv.egovernment.moa.id.ParseException; -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; -import at.gv.egovernment.moa.id.auth.builder.AuthenticationDataAssertionBuilder; -import at.gv.egovernment.moa.id.auth.builder.PersonDataBuilder; -import at.gv.egovernment.moa.id.auth.builder.BPKBuilder; -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; -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.data.VerifyXMLSignatureResponse; -import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; -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.parser.VerifyXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.validator.CreateXMLSignatureResponseValidator; -import at.gv.egovernment.moa.id.auth.validator.ValidateException; -import at.gv.egovernment.moa.id.auth.validator.VerifyXMLSignatureResponseValidator; -import at.gv.egovernment.moa.id.config.ConfigurationException; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; -import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.util.Random; -import at.gv.egovernment.moa.util.DOMUtils; -import at.gv.egovernment.moa.util.DateTimeUtils; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ - -public class Test300VerifyAuthBlock extends AbnahmeTestCase { - - public Test300VerifyAuthBlock(String name) { - super(name); - } - - public void testA301() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - //authDataWriter(authData,this.getName()+"new.xml"); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA302() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - //authDataWriter(authData,this.getName()+"new.xml"); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA303() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA304() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA305() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA306() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA307() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA308() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServer(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - - } - - public void testA309() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA310() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA311() throws Exception { - try { - String sessionID = startAuthentication(); - AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); - assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA351() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - - // nicht existierende Session.... - try { - server.verifyAuthenticationBlock("0", createXMLSignatureResponse); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA352() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - server.setSecondsSessionTimeOut(-100); - server.cleanup(); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - - // abgelaufene Session.... - server.setSecondsSessionTimeOut(1000); - try { - server.verifyAuthenticationBlock("0", createXMLSignatureResponse); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA353() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - - // Session for VerifyIdentityLink-Aufruf - try { - - server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - fail(); - } - //NOCH SEHR UNSCHÖN..... (fliegt raus im AuthenticationServer, Methode buildAuthenticationData - // ( IdentityLink identityLink = session.getIdentityLink(); ==> liefert dann NULL... - catch (NullPointerException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA354() throws Exception { - try { - String sessionID = startAuthentication(); - System.out.println(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - - // nicht existierende Session.... - - server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - try { - server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA355() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ParseException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA356() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ParseException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA357() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA358() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA359() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA360() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA361() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA362() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA363() throws Exception { - try { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA364() throws Exception { - try { - String sessionID = startAuthentication(); - try { - - initServer(sessionID); - fail(); - } - catch (ValidateException e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - /* public void testA365() throws Exception { - String sessionID = startAuthentication(); - try { - // wegen sinnlosigkeit gestrichen - initServer(sessionID); - fail(); - } - catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} - }*/ - - public void testA366() throws Exception { - - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} - } - public void testA367() throws Exception { - String sessionID = startAuthentication(); - try { - initServer(sessionID); - fail(); - } - catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} - } - - - private AuthenticationData initServer(String sessionID) throws Exception { - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, "TrustProfile1"); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - // CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(),"gb","https://localhost:9443/"); - String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - AuthenticationData authData = server.getAuthenticationData(samlArtifact); - return authData; - } - - private AuthenticationData initServerWithoutValidateAuthBlock(String sessionID) throws Exception { - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, "TrustProfile1"); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - // CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(),"gb","https://localhost:9443/"); - - AuthenticationSession session = AuthenticationServer.getSession(sessionID); - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - // parses <CreateXMLSignatureResponse> - CreateXMLSignatureResponse csresp = - new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(); - // validates <CreateXMLSignatureResponse> - new CreateXMLSignatureResponseValidator().validate(csresp, session); - // builds a <VerifyXMLSignatureRequest> for a MOA-SPSS call - String[] vtids = authConf.getMoaSpAuthBlockVerifyTransformsInfoIDs(); - String tpid = authConf.getMoaSpAuthBlockTrustProfileID(); - Element domVsreq = new VerifyXMLSignatureRequestBuilder().build(csresp, vtids, tpid); - // invokes the call - Element domVsresp = new SignatureVerificationInvoker().verifyXMLSignature(domVsreq); - // parses the <VerifyXMLSignatureResponse> - VerifyXMLSignatureResponse vsresp = new VerifyXMLSignatureResponseParser(domVsresp).parseData(); - // validates the <VerifyXMLSignatureResponse> - VerifyXMLSignatureResponseValidator.getInstance().validate(vsresp, null, VerifyXMLSignatureResponseValidator.CHECK_AUTH_BLOCK, true); - // compares the public keys from the identityLink with the AuthBlock - - // builds authentication data and stores it together with a SAML artifact - AuthenticationData authData = buildAuthenticationData(session, vsresp); - return authData; - } - private AuthenticationData buildAuthenticationData( - AuthenticationSession session, - VerifyXMLSignatureResponse verifyXMLSigResp) - throws ConfigurationException, BuildException { - - IdentityLink identityLink = session.getIdentityLink(); - AuthenticationData authData = new AuthenticationData(); - authData.setMajorVersion(1); - authData.setMinorVersion(0); - authData.setAssertionID(Random.nextRandom()); - authData.setIssuer(session.getAuthURL()); - authData.setIssueInstant(DateTimeUtils.buildDateTime(Calendar.getInstance(), false)); - String vpkBase64 = new BPKBuilder().buildBPK( - identityLink.getIdentificationValue(), session.getTarget()); - authData.setBPK(vpkBase64); - authData.setGivenName(identityLink.getGivenName()); - authData.setFamilyName(identityLink.getFamilyName()); - authData.setDateOfBirth(identityLink.getDateOfBirth()); - authData.setQualifiedCertificate(verifyXMLSigResp.isQualifiedCertificate()); - authData.setPublicAuthority(verifyXMLSigResp.isPublicAuthority()); - authData.setPublicAuthorityCode(verifyXMLSigResp.getPublicAuthorityCode()); - OAAuthParameter oaParam = - AuthConfigurationProvider.getInstance().getOnlineApplicationParameter( - session.getPublicOAURLPrefix()); - String prPerson = new PersonDataBuilder().build( - identityLink, oaParam.getProvideStammzahl()); - - try { - String ilAssertion = - oaParam.getProvideIdentityLink() ? DOMUtils.serializeNode(identityLink.getSamlAssertion()) : ""; - String authBlock = oaParam.getProvideAuthBlock() ? session.getAuthBlock() : ""; - String samlAssertion = new AuthenticationDataAssertionBuilder().build( - authData, prPerson, authBlock, ilAssertion, session.getBkuURL(), "", false, null, false, -1); - authData.setSamlAssertion(samlAssertion); - return authData; - } - catch (Throwable ex) { - throw new BuildException( - "builder.00", - new Object[] { "AuthenticationData", ex.getMessage() }, - ex); - } - } -} +///* +// * 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.abnahme.A; +// +//import java.util.Calendar; +//import java.util.HashMap; +// +//import org.w3c.dom.Element; +//import test.abnahme.AbnahmeTestCase; +// +//import at.gv.egovernment.moa.id.AuthenticationException; +//import at.gv.egovernment.moa.id.BuildException; +//import at.gv.egovernment.moa.id.ParseException; +//import at.gv.egovernment.moa.id.auth.AuthenticationServer; +//import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; +//import at.gv.egovernment.moa.id.auth.builder.AuthenticationDataAssertionBuilder; +//import at.gv.egovernment.moa.id.auth.builder.PersonDataBuilder; +//import at.gv.egovernment.moa.id.auth.builder.BPKBuilder; +//import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; +//import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +//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.data.VerifyXMLSignatureResponse; +//import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; +//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.parser.VerifyXMLSignatureResponseParser; +//import at.gv.egovernment.moa.id.auth.validator.CreateXMLSignatureResponseValidator; +//import at.gv.egovernment.moa.id.auth.validator.ValidateException; +//import at.gv.egovernment.moa.id.auth.validator.VerifyXMLSignatureResponseValidator; +//import at.gv.egovernment.moa.id.config.ConfigurationException; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +//import at.gv.egovernment.moa.id.util.Random; +//import at.gv.egovernment.moa.util.DOMUtils; +//import at.gv.egovernment.moa.util.DateTimeUtils; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ +// +//public class Test300VerifyAuthBlock extends AbnahmeTestCase { +// +// public Test300VerifyAuthBlock(String name) { +// super(name); +// } +// +// public void testA301() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// //authDataWriter(authData,this.getName()+"new.xml"); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA302() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// //authDataWriter(authData,this.getName()+"new.xml"); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA303() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA304() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA305() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA306() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA307() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA308() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServer(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// +// } +// +// public void testA309() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA310() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA311() throws Exception { +// try { +// String sessionID = startAuthentication(); +// AuthenticationData authData = initServerWithoutValidateAuthBlock(sessionID); +// assertXmlEquals(readXmldata("AuthenticationData.xml"), clearSamlAssertion(authData.getSamlAssertion())); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA351() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// +// // nicht existierende Session.... +// try { +// server.verifyAuthenticationBlock("0", createXMLSignatureResponse); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA352() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// server.setSecondsSessionTimeOut(-100); +// server.cleanup(); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// +// // abgelaufene Session.... +// server.setSecondsSessionTimeOut(1000); +// try { +// server.verifyAuthenticationBlock("0", createXMLSignatureResponse); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA353() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// +// // Session for VerifyIdentityLink-Aufruf +// try { +// +// server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// fail(); +// } +// //NOCH SEHR UNSCH�N..... (fliegt raus im AuthenticationServer, Methode buildAuthenticationData +// // ( IdentityLink identityLink = session.getIdentityLink(); ==> liefert dann NULL... +// catch (NullPointerException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA354() throws Exception { +// try { +// String sessionID = startAuthentication(); +// System.out.println(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// +// // nicht existierende Session.... +// +// server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// try { +// server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA355() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ParseException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA356() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ParseException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA357() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA358() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA359() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA360() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA361() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA362() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA363() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA364() throws Exception { +// try { +// String sessionID = startAuthentication(); +// try { +// +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// /* public void testA365() throws Exception { +// String sessionID = startAuthentication(); +// try { +// // wegen sinnlosigkeit gestrichen +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} +// }*/ +// +// public void testA366() throws Exception { +// +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} +// } +// public void testA367() throws Exception { +// String sessionID = startAuthentication(); +// try { +// initServer(sessionID); +// fail(); +// } +// catch (ValidateException e) {System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage()+ "-----------------------");} +// } +// +// +// private AuthenticationData initServer(String sessionID) throws Exception { +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, "TrustProfile1"); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// // CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(),"gb","https://localhost:9443/"); +// String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// AuthenticationData authData = server.getAuthenticationData(samlArtifact); +// return authData; +// } +// +// private AuthenticationData initServerWithoutValidateAuthBlock(String sessionID) throws Exception { +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, "TrustProfile1"); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// // CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(),"gb","https://localhost:9443/"); +// +// AuthenticationSession session = AuthenticationServer.getSession(sessionID); +// AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); +// // parses <CreateXMLSignatureResponse> +// CreateXMLSignatureResponse csresp = +// new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(); +// // validates <CreateXMLSignatureResponse> +// new CreateXMLSignatureResponseValidator().validate(csresp, session); +// // builds a <VerifyXMLSignatureRequest> for a MOA-SPSS call +// String[] vtids = authConf.getMoaSpAuthBlockVerifyTransformsInfoIDs(); +// String tpid = authConf.getMoaSpAuthBlockTrustProfileID(); +// Element domVsreq = new VerifyXMLSignatureRequestBuilder().build(csresp, vtids, tpid); +// // invokes the call +// Element domVsresp = new SignatureVerificationInvoker().verifyXMLSignature(domVsreq); +// // parses the <VerifyXMLSignatureResponse> +// VerifyXMLSignatureResponse vsresp = new VerifyXMLSignatureResponseParser(domVsresp).parseData(); +// // validates the <VerifyXMLSignatureResponse> +// VerifyXMLSignatureResponseValidator.getInstance().validate(vsresp, null, VerifyXMLSignatureResponseValidator.CHECK_AUTH_BLOCK, true); +// // compares the public keys from the identityLink with the AuthBlock +// +// // builds authentication data and stores it together with a SAML artifact +// AuthenticationData authData = buildAuthenticationData(session, vsresp); +// return authData; +// } +// private AuthenticationData buildAuthenticationData( +// AuthenticationSession session, +// VerifyXMLSignatureResponse verifyXMLSigResp) +// throws ConfigurationException, BuildException { +// +// IdentityLink identityLink = session.getIdentityLink(); +// AuthenticationData authData = new AuthenticationData(); +// authData.setMajorVersion(1); +// authData.setMinorVersion(0); +// authData.setAssertionID(Random.nextRandom()); +// authData.setIssuer(session.getAuthURL()); +// authData.setIssueInstant(DateTimeUtils.buildDateTime(Calendar.getInstance(), false)); +// String vpkBase64 = new BPKBuilder().buildBPK( +// identityLink.getIdentificationValue(), session.getTarget()); +// authData.setBPK(vpkBase64); +// authData.setGivenName(identityLink.getGivenName()); +// authData.setFamilyName(identityLink.getFamilyName()); +// authData.setDateOfBirth(identityLink.getDateOfBirth()); +// authData.setQualifiedCertificate(verifyXMLSigResp.isQualifiedCertificate()); +// authData.setPublicAuthority(verifyXMLSigResp.isPublicAuthority()); +// authData.setPublicAuthorityCode(verifyXMLSigResp.getPublicAuthorityCode()); +// OAAuthParameter oaParam = +// AuthConfigurationProvider.getInstance().getOnlineApplicationParameter( +// session.getPublicOAURLPrefix()); +// String prPerson = new PersonDataBuilder().build( +// identityLink, oaParam.getProvideStammzahl()); +// +// try { +// String ilAssertion = +// oaParam.getProvideIdentityLink() ? DOMUtils.serializeNode(identityLink.getSamlAssertion()) : ""; +// String authBlock = oaParam.getProvideAuthBlock() ? session.getAuthBlock() : ""; +// String samlAssertion = new AuthenticationDataAssertionBuilder().build( +// authData, prPerson, authBlock, ilAssertion, session.getBkuURL(), "", false, null, false, -1); +// authData.setSamlAssertion(samlAssertion); +// return authData; +// } +// catch (Throwable ex) { +// throw new BuildException( +// "builder.00", +// new Object[] { "AuthenticationData", ex.getMessage() }, +// ex); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test400GetAuthenticationData.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test400GetAuthenticationData.java index 370949ac4..666f16f98 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test400GetAuthenticationData.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test400GetAuthenticationData.java @@ -1,161 +1,161 @@ -/* - * 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.abnahme.A; - -import java.util.HashMap; - -import org.w3c.dom.Element; -import test.abnahme.AbnahmeTestCase; - -import at.gv.egovernment.moa.id.AuthenticationException; -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; -import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; -import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; -import at.gv.egovernment.moa.id.auth.data.IdentityLink; -import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; -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.parser.VerifyXMLSignatureResponseParser; -import at.gv.egovernment.moa.id.auth.validator.CreateXMLSignatureResponseValidator; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.data.AuthenticationData; - -/** - * @author Stefan Knirsch - * @version $Id$ - */ - -public class Test400GetAuthenticationData extends AbnahmeTestCase { - - private String samlArtifact; - - public Test400GetAuthenticationData(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - String sessionID = startAuthentication(); - AuthenticationSession session = AuthenticationServer.getSession(sessionID); - String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - server.verifyIdentityLink(sessionID, parameters); - InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); - IdentityLink idl = irrp.parseIdentityLink(); - Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); - Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); - new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); - //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); - // System.out.println(createXMLSignatureRequest); - String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); - CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(), session); - samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - } - - public void testA401() throws Exception { - try { - - AuthenticationData authData = server.getAuthenticationData(samlArtifact); -// authDataWriter(authData,"NEWA401"); - assertXmlEquals(clearSamlAssertion(authData.getSamlAssertion()), readXmldata("AuthenticationData.xml")); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA451() throws Exception { - try { - try { - AuthenticationData authData = server.getAuthenticationData("AAGu1JFbyGKqJ+3NAonwMu5bNyUc7kooeMK6bxeXBbnK6NL0DfuVJsGi"); - authDataWriter(authData, "A45"); - if (authData != null) - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA452() throws Exception { - try { - server.getAuthenticationData(samlArtifact); - try { - server.getAuthenticationData(samlArtifact); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA453() throws Exception { - try { - server.setSecondsAuthDataTimeOut(-1000); - server.cleanup(); - try { - server.getAuthenticationData(samlArtifact); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA454() throws Exception { - try { - try { - server.getAuthenticationData("blabla123"); - fail(); - } - catch (AuthenticationException e) { - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); - } - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - -} +///* +// * 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.abnahme.A; +// +//import java.util.HashMap; +// +//import org.w3c.dom.Element; +//import test.abnahme.AbnahmeTestCase; +// +//import at.gv.egovernment.moa.id.AuthenticationException; +//import at.gv.egovernment.moa.id.auth.AuthenticationServer; +//import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; +//import at.gv.egovernment.moa.id.auth.builder.VerifyXMLSignatureRequestBuilder; +//import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +//import at.gv.egovernment.moa.id.auth.data.IdentityLink; +//import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker; +//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.parser.VerifyXMLSignatureResponseParser; +//import at.gv.egovernment.moa.id.auth.validator.CreateXMLSignatureResponseValidator; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// */ +// +//public class Test400GetAuthenticationData extends AbnahmeTestCase { +// +// private String samlArtifact; +// +// public Test400GetAuthenticationData(String name) { +// super(name); +// } +// +// protected void setUp() throws Exception { +// super.setUp(); +// String sessionID = startAuthentication(); +// AuthenticationSession session = AuthenticationServer.getSession(sessionID); +// String infoboxReadResponse = readXmldata("InfoBoxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// server.verifyIdentityLink(sessionID, parameters); +// InfoboxReadResponseParser irrp = new InfoboxReadResponseParser(infoboxReadResponse); +// IdentityLink idl = irrp.parseIdentityLink(); +// Element domVerifyXMLSignatureRequest = new VerifyXMLSignatureRequestBuilder().build(idl, AuthConfigurationProvider.getInstance().getMoaSpAuthBlockTrustProfileID()); +// Element domVerifyXMLSignatureResponse = new SignatureVerificationInvoker().verifyXMLSignature(domVerifyXMLSignatureRequest); +// new VerifyXMLSignatureResponseParser(domVerifyXMLSignatureResponse); +// //VerifyXMLSignatureResponseValidator.getInstance().validate(respParser.parseData(), AuthConfigurationProvider.getInstance().getIdentityLinkX509SubjectNames()); +// // System.out.println(createXMLSignatureRequest); +// String createXMLSignatureResponse = readXmldata("CreateXMLSignatureResponse.xml"); +// CreateXMLSignatureResponseValidator.getInstance().validate(new CreateXMLSignatureResponseParser(createXMLSignatureResponse).parseResponse(), session); +// samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// } +// +// public void testA401() throws Exception { +// try { +// +// AuthenticationData authData = server.getAuthenticationData(samlArtifact); +//// authDataWriter(authData,"NEWA401"); +// assertXmlEquals(clearSamlAssertion(authData.getSamlAssertion()), readXmldata("AuthenticationData.xml")); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA451() throws Exception { +// try { +// try { +// AuthenticationData authData = server.getAuthenticationData("AAGu1JFbyGKqJ+3NAonwMu5bNyUc7kooeMK6bxeXBbnK6NL0DfuVJsGi"); +// authDataWriter(authData, "A45"); +// if (authData != null) +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA452() throws Exception { +// try { +// server.getAuthenticationData(samlArtifact); +// try { +// server.getAuthenticationData(samlArtifact); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA453() throws Exception { +// try { +// server.setSecondsAuthDataTimeOut(-1000); +// server.cleanup(); +// try { +// server.getAuthenticationData(samlArtifact); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA454() throws Exception { +// try { +// try { +// server.getAuthenticationData("blabla123"); +// fail(); +// } +// catch (AuthenticationException e) { +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "\n-----------------------"); +// } +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test500StartAuthenticationServlet.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test500StartAuthenticationServlet.java index 2445985ce..eb1e85cb9 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test500StartAuthenticationServlet.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test500StartAuthenticationServlet.java @@ -1,329 +1,329 @@ -/* - * 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.abnahme.A; - -import java.io.OutputStream; -import java.net.URL; -import java.security.Security; - -import javax.net.ssl.SSLSocketFactory; - -import test.abnahme.AbnahmeTestCase; - -import at.gv.egovernment.moa.util.StreamUtils; -import at.gv.egovernment.moa.util.URLEncoder; - -import com.sun.net.ssl.HostnameVerifier; -import com.sun.net.ssl.HttpsURLConnection; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ -public class Test500StartAuthenticationServlet extends AbnahmeTestCase { - - private String testdataRoot = TESTDATA_ROOT + "xmldata/standard/"; - SSLSocketFactory ssf; - public Test500StartAuthenticationServlet(String name) { - super(name); - } - protected void setUp() throws Exception { - super.setUp(); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); - System.setProperty("javax.net.ssl.trustStore", "C:/Programme/ApacheGroup/abnahme/server.keystore"); - System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); - } - - public void testA501() throws Exception { - //NUR einmal für alle folgenden Testfälle - //---------------------------------------- - - //---------------------------------------- - - try { - String targetURL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(targetURL, "GET"); - conn.connect(); - int resultCode = conn.getResponseCode(); - String contentType = conn.getHeaderField("Content-Type"); - if (resultCode != 200) - fail("Wrong HTTP-Code"); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) - fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); - conn.disconnect(); - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA502() throws Exception { - try { - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - int resultCode = conn.getResponseCode(); - String contentType = conn.getHeaderField("Content-Type"); - if (resultCode != 200) - fail("Wrong HTTP-Code: expected '200' and was '" + resultCode + "'"); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) - fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - - conn.disconnect(); - - URL = parseDataURL(result); - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - System.out.println("File gelesen, Daten in Outputstream einpflegen"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes("UTF-8")); - out.flush(); - out.close(); - - System.out.println("Verbinden zu " + URL); - conn.connect(); - resultCode = conn.getResponseCode(); - System.out.println("resultCode :" + resultCode); - String redirectLoc = conn.getHeaderField("Location"); - System.out.println("redirectLoc :" + redirectLoc); - // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! - if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) - fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) - fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); - conn.disconnect(); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA503() throws Exception { - try { - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - - assertEquals(200,conn.getResponseCode()); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) - fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - URL = parseDataURL(result); - - conn.disconnect(); - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - conn.connect(); - String redirectLoc = conn.getHeaderField("Location"); - // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! - if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) - fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) - fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); - conn.disconnect(); - - conn = giveConnection(redirectLoc, "POST"); - System.out.println("Redirect Location: " + redirectLoc); - String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); - out = conn.getOutputStream(); - out.write(("XMLResponse=" +createXMLSignatureResponse).getBytes()); - out.flush(); - out.close(); - - System.out.println("Sending Data to " + redirectLoc); - conn.connect(); - - redirectLoc = conn.getHeaderField("Location"); - System.out.println("redirectLoc: " + redirectLoc); - /* RandomAccessFile raf = new RandomAccessFile("C://503.xml", "rw"); - raf.write(StreamUtils.readStream(conn.getInputStream())); - raf.close();*/ - conn.disconnect(); - assertEquals(302, conn.getResponseCode()); - assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA551() throws Exception { - try { - String targetURL = getURL("https://localhost:8443/moa-id-auth/", "gb", ""); - HttpsURLConnection conn = giveConnection(targetURL, "GET"); - conn.connect(); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - assertTrue(result.indexOf("Die Angabe der Parameter ist unvollständig") >= 0); - conn.disconnect(); - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Die Angabe der Parameter ist unvollständig.\n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA552() throws Exception { - try { - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - int resultCode = conn.getResponseCode(); - assertEquals(200, resultCode); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) - fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); - conn.disconnect(); - URL = "https://localhost:8443/moa-id-auth/" + "VerifyIdentityLink?MOASessionID=0000"; - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - - conn.connect(); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - assertTrue(result.indexOf("MOASessionID ist unbekannt") >= 0); - System.out.println("Fehler in testA552 erfolgreich abgefangen: MOASessionID ist unbekannt"); - conn.disconnect(); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testA553() throws Exception { - try { - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - int resultCode = conn.getResponseCode(); - assertEquals(200,resultCode); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) - fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - String MOASessionID = parseSessionIDFromForm(result); - URL = parseDataURL(result); - conn.disconnect(); - - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - conn.connect(); - result = new String(StreamUtils.readStream(conn.getInputStream())); - String redirectLoc = conn.getHeaderField("Location"); - // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! - if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) - fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); - if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) - fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); - conn.disconnect(); - conn = giveConnection(redirectLoc + "XXX", "POST"); - System.out.println("Redirect Location: " + redirectLoc + "XXX"); - String createXMLSignatureResponse = "XMLResponse=" + URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); - - out = conn.getOutputStream(); - out.write(new String("MOASessionID=" + MOASessionID + "&").getBytes()); - out.write(createXMLSignatureResponse.getBytes("UTF-8")); - out.flush(); - out.close(); - System.out.println("Sending Data to " + redirectLoc); - conn.connect(); - resultCode = conn.getResponseCode(); - - result = new String(StreamUtils.readStream(conn.getInputStream())); - conn.disconnect(); - assertEquals(200, resultCode); - assertTrue(result.indexOf("MOASessionID ist unbekannt") >= 0); - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - private String parseDataURL(String input) { - String ret = getSubString(input.substring(input.indexOf("DataURL"), input.length()), "value=\"", "\""); - return ret; - } - - private String getSubString(String input, String startsWith, String endsWith) { - return input.substring(input.indexOf(startsWith) + startsWith.length(), input.indexOf(endsWith, input.indexOf(startsWith) + startsWith.length())); - } - private String getURL(String authURL, String target, String oaURL) { - return authURL + "StartAuthentication?Target=" + target + "&OA=" + oaURL; - } - private String parseSessionIDFromForm(String htmlForm) { - String parName = "MOASessionID="; - assertTrue("HTML Form enthält keine SessionID", htmlForm.indexOf(parName) >= 0); - int i1 = htmlForm.indexOf(parName) + parName.length(); - int i2 = htmlForm.indexOf("\"", i1); - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } - - private class HostnameVerifierHack implements HostnameVerifier { - public boolean verify(String arg0, String arg1) { - return true; - } - } - private HttpsURLConnection giveConnection(String targetURL, String requestMethod) throws Exception { - URL url = new URL(targetURL); - HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); - conn.setRequestMethod(requestMethod); - conn.setDoInput(true); - conn.setDoOutput(true); - conn.setUseCaches(false); - conn.setAllowUserInteraction(false); - conn.setHostnameVerifier(new HostnameVerifierHack()); - return conn; - } - -}
\ No newline at end of file +///* +// * 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.abnahme.A; +// +//import java.io.OutputStream; +//import java.net.URL; +//import java.security.Security; +// +//import javax.net.ssl.SSLSocketFactory; +// +//import test.abnahme.AbnahmeTestCase; +// +//import at.gv.egovernment.moa.util.StreamUtils; +//import at.gv.egovernment.moa.util.URLEncoder; +// +//import com.sun.net.ssl.HostnameVerifier; +//import com.sun.net.ssl.HttpsURLConnection; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ +//public class Test500StartAuthenticationServlet extends AbnahmeTestCase { +// +// private String testdataRoot = TESTDATA_ROOT + "xmldata/standard/"; +// SSLSocketFactory ssf; +// public Test500StartAuthenticationServlet(String name) { +// super(name); +// } +// protected void setUp() throws Exception { +// super.setUp(); +// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); +// System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); +// System.setProperty("javax.net.ssl.trustStore", "C:/Programme/ApacheGroup/abnahme/server.keystore"); +// System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); +// } +// +// public void testA501() throws Exception { +// //NUR einmal f�r alle folgenden Testf�lle +// //---------------------------------------- +// +// //---------------------------------------- +// +// try { +// String targetURL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(targetURL, "GET"); +// conn.connect(); +// int resultCode = conn.getResponseCode(); +// String contentType = conn.getHeaderField("Content-Type"); +// if (resultCode != 200) +// fail("Wrong HTTP-Code"); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) +// fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); +// conn.disconnect(); +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA502() throws Exception { +// try { +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// int resultCode = conn.getResponseCode(); +// String contentType = conn.getHeaderField("Content-Type"); +// if (resultCode != 200) +// fail("Wrong HTTP-Code: expected '200' and was '" + resultCode + "'"); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) +// fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// +// conn.disconnect(); +// +// URL = parseDataURL(result); +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// System.out.println("File gelesen, Daten in Outputstream einpflegen"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes("UTF-8")); +// out.flush(); +// out.close(); +// +// System.out.println("Verbinden zu " + URL); +// conn.connect(); +// resultCode = conn.getResponseCode(); +// System.out.println("resultCode :" + resultCode); +// String redirectLoc = conn.getHeaderField("Location"); +// System.out.println("redirectLoc :" + redirectLoc); +// // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! +// if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) +// fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) +// fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); +// conn.disconnect(); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA503() throws Exception { +// try { +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// +// assertEquals(200,conn.getResponseCode()); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) +// fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// URL = parseDataURL(result); +// +// conn.disconnect(); +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// conn.connect(); +// String redirectLoc = conn.getHeaderField("Location"); +// // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! +// if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) +// fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) +// fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); +// conn.disconnect(); +// +// conn = giveConnection(redirectLoc, "POST"); +// System.out.println("Redirect Location: " + redirectLoc); +// String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); +// out = conn.getOutputStream(); +// out.write(("XMLResponse=" +createXMLSignatureResponse).getBytes()); +// out.flush(); +// out.close(); +// +// System.out.println("Sending Data to " + redirectLoc); +// conn.connect(); +// +// redirectLoc = conn.getHeaderField("Location"); +// System.out.println("redirectLoc: " + redirectLoc); +// /* RandomAccessFile raf = new RandomAccessFile("C://503.xml", "rw"); +// raf.write(StreamUtils.readStream(conn.getInputStream())); +// raf.close();*/ +// conn.disconnect(); +// assertEquals(302, conn.getResponseCode()); +// assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA551() throws Exception { +// try { +// String targetURL = getURL("https://localhost:8443/moa-id-auth/", "gb", ""); +// HttpsURLConnection conn = giveConnection(targetURL, "GET"); +// conn.connect(); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// assertTrue(result.indexOf("Die Angabe der Parameter ist unvollständig") >= 0); +// conn.disconnect(); +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Die Angabe der Parameter ist unvollst�ndig.\n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA552() throws Exception { +// try { +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// int resultCode = conn.getResponseCode(); +// assertEquals(200, resultCode); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) +// fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); +// conn.disconnect(); +// URL = "https://localhost:8443/moa-id-auth/" + "VerifyIdentityLink?MOASessionID=0000"; +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// +// conn.connect(); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// assertTrue(result.indexOf("MOASessionID ist unbekannt") >= 0); +// System.out.println("Fehler in testA552 erfolgreich abgefangen: MOASessionID ist unbekannt"); +// conn.disconnect(); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testA553() throws Exception { +// try { +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// int resultCode = conn.getResponseCode(); +// assertEquals(200,resultCode); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/html")) +// fail("Wrong contentType: expected text/html and was " + conn.getHeaderField("Content-Type")); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// String MOASessionID = parseSessionIDFromForm(result); +// URL = parseDataURL(result); +// conn.disconnect(); +// +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// conn.connect(); +// result = new String(StreamUtils.readStream(conn.getInputStream())); +// String redirectLoc = conn.getHeaderField("Location"); +// // Austausch von VerifyIdentityLink in der POST-URL durch VerifyAuthBlock... rest MUSS gleich sein! +// if (!killInclusive(URL, "VerifyI", "Link", "VerifyAuthBlock").equals(redirectLoc)) +// fail("Wrong Redirect-Location: expected " + URL + " and was " + conn.getHeaderField("Location")); +// if (!conn.getHeaderField("Content-Type").equalsIgnoreCase("text/xml")) +// fail("Wrong contentType: expected text/xml and was " + conn.getHeaderField("Content-Type")); +// conn.disconnect(); +// conn = giveConnection(redirectLoc + "XXX", "POST"); +// System.out.println("Redirect Location: " + redirectLoc + "XXX"); +// String createXMLSignatureResponse = "XMLResponse=" + URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); +// +// out = conn.getOutputStream(); +// out.write(new String("MOASessionID=" + MOASessionID + "&").getBytes()); +// out.write(createXMLSignatureResponse.getBytes("UTF-8")); +// out.flush(); +// out.close(); +// System.out.println("Sending Data to " + redirectLoc); +// conn.connect(); +// resultCode = conn.getResponseCode(); +// +// result = new String(StreamUtils.readStream(conn.getInputStream())); +// conn.disconnect(); +// assertEquals(200, resultCode); +// assertTrue(result.indexOf("MOASessionID ist unbekannt") >= 0); +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// private String parseDataURL(String input) { +// String ret = getSubString(input.substring(input.indexOf("DataURL"), input.length()), "value=\"", "\""); +// return ret; +// } +// +// private String getSubString(String input, String startsWith, String endsWith) { +// return input.substring(input.indexOf(startsWith) + startsWith.length(), input.indexOf(endsWith, input.indexOf(startsWith) + startsWith.length())); +// } +// private String getURL(String authURL, String target, String oaURL) { +// return authURL + "StartAuthentication?Target=" + target + "&OA=" + oaURL; +// } +// private String parseSessionIDFromForm(String htmlForm) { +// String parName = "MOASessionID="; +// assertTrue("HTML Form enth�lt keine SessionID", htmlForm.indexOf(parName) >= 0); +// int i1 = htmlForm.indexOf(parName) + parName.length(); +// int i2 = htmlForm.indexOf("\"", i1); +// assertTrue("HTML Form enth�lt keine g�ltige SessionID", i2 > i1); +// return htmlForm.substring(i1, i2); +// } +// +// private class HostnameVerifierHack implements HostnameVerifier { +// public boolean verify(String arg0, String arg1) { +// return true; +// } +// } +// private HttpsURLConnection giveConnection(String targetURL, String requestMethod) throws Exception { +// URL url = new URL(targetURL); +// HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); +// conn.setRequestMethod(requestMethod); +// conn.setDoInput(true); +// conn.setDoOutput(true); +// conn.setUseCaches(false); +// conn.setAllowUserInteraction(false); +// conn.setHostnameVerifier(new HostnameVerifierHack()); +// return conn; +// } +// +//}
\ No newline at end of file diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test600GetAuthenticationDataService.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test600GetAuthenticationDataService.java index fab258e09..c973473a6 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test600GetAuthenticationDataService.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test600GetAuthenticationDataService.java @@ -1,305 +1,305 @@ -/* - * 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.abnahme.A; - -import java.io.OutputStream; -import java.net.URL; -import java.security.Security; -import java.util.Calendar; -import java.util.Vector; - -import javax.xml.namespace.QName; -import javax.xml.rpc.Call; -import javax.xml.rpc.Service; -import javax.xml.rpc.ServiceFactory; - -import org.apache.axis.message.SOAPBodyElement; -import org.w3c.dom.Element; - -import com.sun.net.ssl.HostnameVerifier; -import com.sun.net.ssl.HttpsURLConnection; - -import test.abnahme.AbnahmeTestCase; - -import at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilder; -import at.gv.egovernment.moa.util.DOMUtils; -import at.gv.egovernment.moa.util.DateTimeUtils; -import at.gv.egovernment.moa.util.StreamUtils; -import at.gv.egovernment.moa.util.URLDecoder; -import at.gv.egovernment.moa.util.URLEncoder; - -/** - * @author Stefan Knirsch - * @version $Id$ - */ - -public class Test600GetAuthenticationDataService extends AbnahmeTestCase { - - private String moaSessionID; - private String samlArtifact; - private static final QName SERVICE_QNAME = new QName("SignatureCreation"); - - public Test600GetAuthenticationDataService(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); - System.setProperty("javax.net.ssl.trustStore", "C:/Programme/ApacheGroup/abnahme/server.keystore"); - System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); - } - - public void testA601() throws Exception { - try { - - // Anmelden - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - String MOASessionID = parseSessionIDFromForm(result); - conn.disconnect(); - - URL = parseDataURL(result); - // Verify Identity Link - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - conn.connect(); - String redirectLoc = conn.getHeaderField("Location"); - conn.disconnect(); - //Verify Auth Block - conn = giveConnection(redirectLoc, "POST"); - String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); - out = conn.getOutputStream(); - out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); - out.flush(); - out.close(); - conn.connect(); - redirectLoc = conn.getHeaderField("Location"); - samlArtifact = parseSamlArtifact(redirectLoc); - System.out.println("SamlArtifact: " + samlArtifact); - conn.disconnect(); - - assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); - - conn = null; - - SAMLRequestBuilder srb = new SAMLRequestBuilder(); - - Element erg = doCall(srb.build(moaSessionID,URLDecoder.decode(samlArtifact, "UTF-8"))); - result = DOMUtils.serializeNode(erg); - result = killInclusive(result,"IssueInstant=\"","\"",""); - result = killInclusive(result,"AssertionID=\"","\"",""); - result = killInclusive(result,"ResponseID=\"","\"",""); - -// writeXmldata("GetAuthenticationDataWebServiceResponse.xml", result.getBytes("UTF-8")); - - assertEquals(result,readXmldata("GetAuthenticationDataWebServiceResponse.xml")); - - System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA651() throws Exception { - try { - - // Anmelden - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - String MOASessionID = parseSessionIDFromForm(result); - conn.disconnect(); - - URL = parseDataURL(result); - // Verify Identity Link - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - conn.connect(); - String redirectLoc = conn.getHeaderField("Location"); - conn.disconnect(); - //Verify Auth Block - conn = giveConnection(redirectLoc, "POST"); - String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); - out = conn.getOutputStream(); - out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); - out.flush(); - out.close(); - conn.connect(); - redirectLoc = conn.getHeaderField("Location"); - samlArtifact = "AAGu1JFbyGKqJ+3NAonwMu5bNyUc7kooeMK6bxeXBbnK6NL0DfuVJsGi"; - System.out.println("SamlArtifact: " + samlArtifact); - conn.disconnect(); - - assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); - - conn = null; - - SAMLRequestBuilder srb = new SAMLRequestBuilder(); - Element samlPRequest = srb.build(moaSessionID,samlArtifact); - - assertTrue(DOMUtils.serializeNode(doCall(samlPRequest)).indexOf("unbekanntes SAML-Artifakt")!=-1); - - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Fehler beim Abholen der Anmeldedaten, unbekanntes SAML-Artifakt\n-----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - public void testA652() throws Exception { - try { - - // Anmelden - String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); - HttpsURLConnection conn = giveConnection(URL, "GET"); - conn.connect(); - String result = new String(StreamUtils.readStream(conn.getInputStream())); - String MOASessionID = parseSessionIDFromForm(result); - conn.disconnect(); - - URL = parseDataURL(result); - // Verify Identity Link - conn = giveConnection(URL, "POST"); - conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); - OutputStream out = conn.getOutputStream(); - out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); - out.flush(); - out.close(); - conn.connect(); - String redirectLoc = conn.getHeaderField("Location"); - conn.disconnect(); - //Verify Auth Block - conn = giveConnection(redirectLoc, "POST"); - String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); - out = conn.getOutputStream(); - out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); - out.flush(); - out.close(); - conn.connect(); - redirectLoc = conn.getHeaderField("Location"); - samlArtifact = parseSamlArtifact(redirectLoc); - System.out.println("SamlArtifact: " + samlArtifact); - conn.disconnect(); - - assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); - - conn = null; - String request = - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" RequestID=\"" + - moaSessionID + "\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"" + - DateTimeUtils.buildDateTime(Calendar.getInstance(), false)+"\">" + - "</samlp:Request>"; - - Element samlPRequest = DOMUtils.parseDocument(request, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - - assertTrue(DOMUtils.serializeNode(doCall(samlPRequest)).indexOf("Fehlerhaftes Requestformat")!=-1); -// writeXmldata("GetAuthenticationDataWebServiceResponse.xml", result.getBytes("UTF-8")); - System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Fehlerhaftes Requestformat\n-----------------------"); } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - - protected Element doCall(Element request) - throws Exception { - QName serviceName = new QName("GetAuthenticationData"); - String endPoint = "http://localhost:8080/moa-id-auth/services/GetAuthenticationData"; - Service service = ServiceFactory.newInstance().createService(serviceName); - Call call = service.createCall(); - SOAPBodyElement body = - new SOAPBodyElement(request); - SOAPBodyElement[] params = new SOAPBodyElement[] {body}; - Vector responses; - SOAPBodyElement response; - - call.setTargetEndpointAddress(endPoint); - responses = (Vector) call.invoke(params); - response = (SOAPBodyElement) responses.get(0); - - return response.getAsDOM(); - } - - private String parseDataURL(String input) - { - return getSubString(input.substring(input.indexOf("DataURL"),input.length()),"value=\"","\""); - } - private String parseSamlArtifact(String input) - { - return getSubString(input+"@@@","SAMLArtifact=","@@@"); - } - private String getSubString(String input, String startsWith, String endsWith) - { - return input.substring(input.indexOf(startsWith)+startsWith.length(), input.indexOf(endsWith, input.indexOf(startsWith)+startsWith.length())); - } - private String getURL(String authURL, String target, String oaURL) - { - return authURL + "StartAuthentication?Target=" + target + "&OA=" + oaURL; - } - private String parseSessionIDFromForm(String htmlForm) { - String parName = "MOASessionID="; - assertTrue( - "HTML Form enthält keine SessionID", - htmlForm.indexOf(parName) >= 0); - int i1 = htmlForm.indexOf(parName) + parName.length(); - int i2 = htmlForm.indexOf("\"", i1); - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } - private HttpsURLConnection giveConnection(String targetURL, String requestMethod) throws Exception { - HttpsURLConnection conn = (HttpsURLConnection) new URL(targetURL).openConnection(); - conn.setRequestMethod(requestMethod); - conn.setDoInput(true); - conn.setDoOutput(true); - conn.setUseCaches(false); - conn.setAllowUserInteraction(false); - conn.setHostnameVerifier(new HostnameVerifierHack()); - return conn; - } - private class HostnameVerifierHack implements HostnameVerifier { - public boolean verify(String arg0, String arg1) { - return true; - } - } -} +///* +// * 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.abnahme.A; +// +//import java.io.OutputStream; +//import java.net.URL; +//import java.security.Security; +//import java.util.Calendar; +//import java.util.Vector; +// +//import javax.xml.namespace.QName; +//import javax.xml.rpc.Call; +//import javax.xml.rpc.Service; +//import javax.xml.rpc.ServiceFactory; +// +//import org.apache.axis.message.SOAPBodyElement; +//import org.w3c.dom.Element; +// +//import com.sun.net.ssl.HostnameVerifier; +//import com.sun.net.ssl.HttpsURLConnection; +// +//import test.abnahme.AbnahmeTestCase; +// +//import at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilder; +//import at.gv.egovernment.moa.util.DOMUtils; +//import at.gv.egovernment.moa.util.DateTimeUtils; +//import at.gv.egovernment.moa.util.StreamUtils; +//import at.gv.egovernment.moa.util.URLDecoder; +//import at.gv.egovernment.moa.util.URLEncoder; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// */ +// +//public class Test600GetAuthenticationDataService extends AbnahmeTestCase { +// +// private String moaSessionID; +// private String samlArtifact; +// private static final QName SERVICE_QNAME = new QName("SignatureCreation"); +// +// public Test600GetAuthenticationDataService(String name) { +// super(name); +// } +// +// protected void setUp() throws Exception { +// super.setUp(); +// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); +// System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); +// System.setProperty("javax.net.ssl.trustStore", "C:/Programme/ApacheGroup/abnahme/server.keystore"); +// System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); +// } +// +// public void testA601() throws Exception { +// try { +// +// // Anmelden +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// String MOASessionID = parseSessionIDFromForm(result); +// conn.disconnect(); +// +// URL = parseDataURL(result); +// // Verify Identity Link +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// conn.connect(); +// String redirectLoc = conn.getHeaderField("Location"); +// conn.disconnect(); +// //Verify Auth Block +// conn = giveConnection(redirectLoc, "POST"); +// String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); +// out = conn.getOutputStream(); +// out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); +// out.flush(); +// out.close(); +// conn.connect(); +// redirectLoc = conn.getHeaderField("Location"); +// samlArtifact = parseSamlArtifact(redirectLoc); +// System.out.println("SamlArtifact: " + samlArtifact); +// conn.disconnect(); +// +// assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); +// +// conn = null; +// +// SAMLRequestBuilder srb = new SAMLRequestBuilder(); +// +// Element erg = doCall(srb.build(moaSessionID,URLDecoder.decode(samlArtifact, "UTF-8"))); +// result = DOMUtils.serializeNode(erg); +// result = killInclusive(result,"IssueInstant=\"","\"",""); +// result = killInclusive(result,"AssertionID=\"","\"",""); +// result = killInclusive(result,"ResponseID=\"","\"",""); +// +//// writeXmldata("GetAuthenticationDataWebServiceResponse.xml", result.getBytes("UTF-8")); +// +// assertEquals(result,readXmldata("GetAuthenticationDataWebServiceResponse.xml")); +// +// System.out.println("-----------------------\nTestfall " + this.getName() + " erfolgreich abgearbeitet! \n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA651() throws Exception { +// try { +// +// // Anmelden +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// String MOASessionID = parseSessionIDFromForm(result); +// conn.disconnect(); +// +// URL = parseDataURL(result); +// // Verify Identity Link +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// conn.connect(); +// String redirectLoc = conn.getHeaderField("Location"); +// conn.disconnect(); +// //Verify Auth Block +// conn = giveConnection(redirectLoc, "POST"); +// String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); +// out = conn.getOutputStream(); +// out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); +// out.flush(); +// out.close(); +// conn.connect(); +// redirectLoc = conn.getHeaderField("Location"); +// samlArtifact = "AAGu1JFbyGKqJ+3NAonwMu5bNyUc7kooeMK6bxeXBbnK6NL0DfuVJsGi"; +// System.out.println("SamlArtifact: " + samlArtifact); +// conn.disconnect(); +// +// assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); +// +// conn = null; +// +// SAMLRequestBuilder srb = new SAMLRequestBuilder(); +// Element samlPRequest = srb.build(moaSessionID,samlArtifact); +// +// assertTrue(DOMUtils.serializeNode(doCall(samlPRequest)).indexOf("unbekanntes SAML-Artifakt")!=-1); +// +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Fehler beim Abholen der Anmeldedaten, unbekanntes SAML-Artifakt\n-----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// public void testA652() throws Exception { +// try { +// +// // Anmelden +// String URL = getURL("https://localhost:8443/moa-id-auth/", "gb", "https://localhost:9443/"); +// HttpsURLConnection conn = giveConnection(URL, "GET"); +// conn.connect(); +// String result = new String(StreamUtils.readStream(conn.getInputStream())); +// String MOASessionID = parseSessionIDFromForm(result); +// conn.disconnect(); +// +// URL = parseDataURL(result); +// // Verify Identity Link +// conn = giveConnection(URL, "POST"); +// conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); +// String infoboxReadResponse = readXmldata("InfoboxReadResponse.xml"); +// OutputStream out = conn.getOutputStream(); +// out.write(new String("XMLResponse=" + URLEncoder.encode(infoboxReadResponse, "UTF-8")).getBytes()); +// out.flush(); +// out.close(); +// conn.connect(); +// String redirectLoc = conn.getHeaderField("Location"); +// conn.disconnect(); +// //Verify Auth Block +// conn = giveConnection(redirectLoc, "POST"); +// String createXMLSignatureResponse = URLEncoder.encode(readXmldata("CreateXMLSignatureResponse.xml"), "UTF-8"); +// out = conn.getOutputStream(); +// out.write(("MOASessionID=" + moaSessionID + "&XMLResponse=" + createXMLSignatureResponse).getBytes("UTF-8")); +// out.flush(); +// out.close(); +// conn.connect(); +// redirectLoc = conn.getHeaderField("Location"); +// samlArtifact = parseSamlArtifact(redirectLoc); +// System.out.println("SamlArtifact: " + samlArtifact); +// conn.disconnect(); +// +// assertTrue(redirectLoc.startsWith("https://localhost:9443/?Target=gb&SAMLArtifact=")); +// +// conn = null; +// String request = +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" RequestID=\"" + +// moaSessionID + "\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"" + +// DateTimeUtils.buildDateTime(Calendar.getInstance(), false)+"\">" + +// "</samlp:Request>"; +// +// Element samlPRequest = DOMUtils.parseDocument(request, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// +// assertTrue(DOMUtils.serializeNode(doCall(samlPRequest)).indexOf("Fehlerhaftes Requestformat")!=-1); +//// writeXmldata("GetAuthenticationDataWebServiceResponse.xml", result.getBytes("UTF-8")); +// System.out.println("-----------------------\nFehler in " + this.getName() + " erfolgreich abgefangen: Fehlerhaftes Requestformat\n-----------------------"); } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// +// protected Element doCall(Element request) +// throws Exception { +// QName serviceName = new QName("GetAuthenticationData"); +// String endPoint = "http://localhost:8080/moa-id-auth/services/GetAuthenticationData"; +// Service service = ServiceFactory.newInstance().createService(serviceName); +// Call call = service.createCall(); +// SOAPBodyElement body = +// new SOAPBodyElement(request); +// SOAPBodyElement[] params = new SOAPBodyElement[] {body}; +// Vector responses; +// SOAPBodyElement response; +// +// call.setTargetEndpointAddress(endPoint); +// responses = (Vector) call.invoke(params); +// response = (SOAPBodyElement) responses.get(0); +// +// return response.getAsDOM(); +// } +// +// private String parseDataURL(String input) +// { +// return getSubString(input.substring(input.indexOf("DataURL"),input.length()),"value=\"","\""); +// } +// private String parseSamlArtifact(String input) +// { +// return getSubString(input+"@@@","SAMLArtifact=","@@@"); +// } +// private String getSubString(String input, String startsWith, String endsWith) +// { +// return input.substring(input.indexOf(startsWith)+startsWith.length(), input.indexOf(endsWith, input.indexOf(startsWith)+startsWith.length())); +// } +// private String getURL(String authURL, String target, String oaURL) +// { +// return authURL + "StartAuthentication?Target=" + target + "&OA=" + oaURL; +// } +// private String parseSessionIDFromForm(String htmlForm) { +// String parName = "MOASessionID="; +// assertTrue( +// "HTML Form enth�lt keine SessionID", +// htmlForm.indexOf(parName) >= 0); +// int i1 = htmlForm.indexOf(parName) + parName.length(); +// int i2 = htmlForm.indexOf("\"", i1); +// assertTrue("HTML Form enth�lt keine g�ltige SessionID", i2 > i1); +// return htmlForm.substring(i1, i2); +// } +// private HttpsURLConnection giveConnection(String targetURL, String requestMethod) throws Exception { +// HttpsURLConnection conn = (HttpsURLConnection) new URL(targetURL).openConnection(); +// conn.setRequestMethod(requestMethod); +// conn.setDoInput(true); +// conn.setDoOutput(true); +// conn.setUseCaches(false); +// conn.setAllowUserInteraction(false); +// conn.setHostnameVerifier(new HostnameVerifierHack()); +// return conn; +// } +// private class HostnameVerifierHack implements HostnameVerifier { +// public boolean verify(String arg0, String arg1) { +// return true; +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/A/Test700SelectBKU.java b/id/server/idserverlib/src/test/java/test/abnahme/A/Test700SelectBKU.java index 386a2b454..120e6dc44 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/A/Test700SelectBKU.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/A/Test700SelectBKU.java @@ -1,87 +1,87 @@ -/* - * 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.abnahme.A; - -import test.abnahme.AbnahmeTestCase; - -/* - * @author Paul Ivancsics - * @version $Id$ - */ -public class Test700SelectBKU extends AbnahmeTestCase { - - public Test700SelectBKU(String name) { - super(name); - } - - public void testA701() throws Exception { - try { - String form = server.selectBKU( - "https://localhost:8443/auth", - "gb", - "https://localhost:9443/", - "file:" + getTestCaseDirectory() + "BKUSelectionTemplate.html", - "file:" + getTestCaseDirectory() + "Template.html"); - //writeXmldata("SelectBKUForm_out.html", form.getBytes()); - assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); - } - catch (Exception ex) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); - throw ex; - } - } - public void testA702() throws Exception { - try { - String form = server.selectBKU( - "https://localhost:8443/auth", - "gb", - "https://localhost:9443/", - null, - null); - //writeXmldata("SelectBKUForm_out.html", form.getBytes()); - assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); - } - catch (Exception ex) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); - throw ex; - } - } - public void testA703() throws Exception { - try { - String form = server.selectBKU( - "https://localhost:8443/auth", - "gb", - "https://localhost:9443/", - null, - null); - //writeXmldata("SelectBKUForm_out.html", form.getBytes()); - assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); - } - catch (Exception ex) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); - throw ex; - } - } -} +///* +// * 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.abnahme.A; +// +//import test.abnahme.AbnahmeTestCase; +// +///* +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class Test700SelectBKU extends AbnahmeTestCase { +// +// public Test700SelectBKU(String name) { +// super(name); +// } +// +// public void testA701() throws Exception { +// try { +// String form = server.selectBKU( +// "https://localhost:8443/auth", +// "gb", +// "https://localhost:9443/", +// "file:" + getTestCaseDirectory() + "BKUSelectionTemplate.html", +// "file:" + getTestCaseDirectory() + "Template.html"); +// //writeXmldata("SelectBKUForm_out.html", form.getBytes()); +// assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); +// } +// catch (Exception ex) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); +// throw ex; +// } +// } +// public void testA702() throws Exception { +// try { +// String form = server.selectBKU( +// "https://localhost:8443/auth", +// "gb", +// "https://localhost:9443/", +// null, +// null); +// //writeXmldata("SelectBKUForm_out.html", form.getBytes()); +// assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); +// } +// catch (Exception ex) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); +// throw ex; +// } +// } +// public void testA703() throws Exception { +// try { +// String form = server.selectBKU( +// "https://localhost:8443/auth", +// "gb", +// "https://localhost:9443/", +// null, +// null); +// //writeXmldata("SelectBKUForm_out.html", form.getBytes()); +// assertEqualsIgnoreSessionID(readXmldata("SelectBKUForm.html"), form); +// } +// catch (Exception ex) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + ex.getLocalizedMessage()); +// throw ex; +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java b/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java index 8e38c7673..7caa6dd8c 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/AbnahmeTestCase.java @@ -1,190 +1,190 @@ -/* - * 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.abnahme; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; - -import test.MOAIDTestCase; - -import at.gv.egovernment.moa.id.MOAIDException; -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.data.AuthenticationData; - -/** - * Base class for MOA ID test cases. - * - * Provides some utility functions. - * - * @author Stefan Knirsch - * @version $Id$ - */ -public class AbnahmeTestCase extends MOAIDTestCase { - - protected static final String TESTDATA_ROOT = "data/abnahme-test/"; - protected static final String TESTDATA_XMLDATA = "data/abnahme-test/xmldata/"; - protected static final String AUTH_ENDPOINT = "http://localhost:8080/moa-id-auth/"; - protected AuthenticationServer server; - - /** - * Constructor for MOATestCase. - * @param arg0 - */ - public AbnahmeTestCase(String name) { - super(name); - } - /** - * Set up a transaction context with a test configuration. - */ - protected void setUp() throws Exception { - - System.out.print("--------S-T-A-R-T----V-O-N----"); - System.out.print(getName().toUpperCase().substring(4,getName().length())); - System.out.print("-----------------------------\n"); - - // Set moa.spss.server.configuration property - System.setProperty("moa.spss.server.configuration",TESTDATA_ROOT + "conf/moa/ConfigurationTest.xml"); - - // Set moa.id.configuration property - String pathname = findXmldata("Configuration.xml"); - System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); - System.out.println("Konfiguration " + pathname); - AuthConfigurationProvider.reload(); - - server = AuthenticationServer.getInstance(); - } - /** Test case z.B. "A153" */ - protected String getID() { - return getName().toUpperCase().substring(4,getName().length()); - } - /** Test group z.B. "A100" */ - protected String getTestGroup() { - return getID().substring(0, 2) + "00"; - } - /** Test case data directory */ - protected String getTestCaseDirectory() { - return getTestGroupDirectory() + getID() + "/"; - } - /** Test group data directory */ - protected String getTestGroupDirectory() { - return TESTDATA_XMLDATA + getTestGroup() + "/"; - } - /** Finds a file in the xmldata directory */ - protected String findXmldata(String filename) { - String pathname = getTestCaseDirectory() + filename; - if (! new File(pathname).exists()) { - pathname = getTestGroupDirectory() + filename; - if (! new File(pathname).exists()) { - pathname = TESTDATA_XMLDATA + filename; - } - } - return pathname; - } - /** Finds and reads a file in the xmldata directory */ - protected String readXmldata(String filename) throws IOException { - String pathname = findXmldata(filename); - System.out.println("Read file " + pathname); - return readFile(pathname); - } - protected void writeXmldata(String filename, byte[] content) throws Exception { - String pathname = getTestCaseDirectory() + filename; - System.out.println("Write file " + pathname); - RandomAccessFile raf = new RandomAccessFile(pathname, "rw"); - byte[] data = content; - raf.write(data); - raf.setLength(data.length); - raf.close(); - } - - /** - * Creates a session using standard parameters, - * and returns the session ID. - */ - protected String startAuthentication() throws MOAIDException { - return startAuthentication("https://localhost:9443/"); - } - /** - * Creates a session using standard parameters, - * and returns the session ID. - */ - protected String startAuthentication(String oaURL) throws MOAIDException { - String htmlForm = AuthenticationServer.getInstance().startAuthentication( - "https://localhost:8443/auth", - "gb", - null, - oaURL, - null, - null, - null, - null, - null, null); - String sessionID = parseSessionIDFromForm(htmlForm); - return sessionID; - } - private String parseSessionIDFromForm(String htmlForm) { - String parName = "MOASessionID="; - assertTrue( - "HTML Form enthält keine SessionID", - htmlForm.indexOf(parName) >= 0); - int i1 = htmlForm.indexOf(parName) + parName.length(); - int i2 = i1; - while(i2 < htmlForm.length() && - (htmlForm.charAt(i2) == '-' || (htmlForm.charAt(i2) >= '0' && htmlForm.charAt(i2) <= '9'))) - i2++; - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } - protected String clearSessionID(String htmlForm) { - String sessionID = parseSessionIDFromForm(htmlForm); - int i1 = htmlForm.indexOf(sessionID); - int i2 = i1 + sessionID.length(); - return htmlForm.substring(0, i1) + htmlForm.substring(i2); - } - protected void assertEqualsIgnoreSessionID(String s1, String s2) { - String ss1 = clearSessionID(s1); - String ss2 = clearSessionID(s2); - assertEquals(ss1, ss2); - } - protected void authDataWriter(AuthenticationData authData, String filename) throws Exception - { - writeXmldata("AuthenticationDataNEW.xml", clearSamlAssertion(authData.getSamlAssertion()).getBytes("UTF-8")); - } - - /** - * clearSamlAssertion löscht aus einer beliebiegen String-Repräsentation einer XML-Struktur - * AUSSLIESSLICH die Attribute 'IssueInstant' und 'AssertionID' heraus. - * @param samlAssertion - * @return String - */ - protected String clearSamlAssertion(String samlAssertion) - { - String result = killInclusive(samlAssertion,"IssueInstant='", "'",""); - result = killInclusive(result,"AssertionID='", "'",""); - return result; - } -}
\ No newline at end of file +///* +// * 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.abnahme; +// +//import java.io.File; +//import java.io.IOException; +//import java.io.RandomAccessFile; +// +//import test.MOAIDTestCase; +// +//import at.gv.egovernment.moa.id.MOAIDException; +//import at.gv.egovernment.moa.id.auth.AuthenticationServer; +//import at.gv.egovernment.moa.id.config.ConfigurationProvider; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +// +///** +// * Base class for MOA ID test cases. +// * +// * Provides some utility functions. +// * +// * @author Stefan Knirsch +// * @version $Id$ +// */ +//public class AbnahmeTestCase extends MOAIDTestCase { +// +// protected static final String TESTDATA_ROOT = "data/abnahme-test/"; +// protected static final String TESTDATA_XMLDATA = "data/abnahme-test/xmldata/"; +// protected static final String AUTH_ENDPOINT = "http://localhost:8080/moa-id-auth/"; +// protected AuthenticationServer server; +// +// /** +// * Constructor for MOATestCase. +// * @param arg0 +// */ +// public AbnahmeTestCase(String name) { +// super(name); +// } +// /** +// * Set up a transaction context with a test configuration. +// */ +// protected void setUp() throws Exception { +// +// System.out.print("--------S-T-A-R-T----V-O-N----"); +// System.out.print(getName().toUpperCase().substring(4,getName().length())); +// System.out.print("-----------------------------\n"); +// +// // Set moa.spss.server.configuration property +// System.setProperty("moa.spss.server.configuration",TESTDATA_ROOT + "conf/moa/ConfigurationTest.xml"); +// +// // Set moa.id.configuration property +// String pathname = findXmldata("Configuration.xml"); +// System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); +// System.out.println("Konfiguration " + pathname); +// AuthConfigurationProvider.reload(); +// +// server = AuthenticationServer.getInstance(); +// } +// /** Test case z.B. "A153" */ +// protected String getID() { +// return getName().toUpperCase().substring(4,getName().length()); +// } +// /** Test group z.B. "A100" */ +// protected String getTestGroup() { +// return getID().substring(0, 2) + "00"; +// } +// /** Test case data directory */ +// protected String getTestCaseDirectory() { +// return getTestGroupDirectory() + getID() + "/"; +// } +// /** Test group data directory */ +// protected String getTestGroupDirectory() { +// return TESTDATA_XMLDATA + getTestGroup() + "/"; +// } +// /** Finds a file in the xmldata directory */ +// protected String findXmldata(String filename) { +// String pathname = getTestCaseDirectory() + filename; +// if (! new File(pathname).exists()) { +// pathname = getTestGroupDirectory() + filename; +// if (! new File(pathname).exists()) { +// pathname = TESTDATA_XMLDATA + filename; +// } +// } +// return pathname; +// } +// /** Finds and reads a file in the xmldata directory */ +// protected String readXmldata(String filename) throws IOException { +// String pathname = findXmldata(filename); +// System.out.println("Read file " + pathname); +// return readFile(pathname); +// } +// protected void writeXmldata(String filename, byte[] content) throws Exception { +// String pathname = getTestCaseDirectory() + filename; +// System.out.println("Write file " + pathname); +// RandomAccessFile raf = new RandomAccessFile(pathname, "rw"); +// byte[] data = content; +// raf.write(data); +// raf.setLength(data.length); +// raf.close(); +// } +// +// /** +// * Creates a session using standard parameters, +// * and returns the session ID. +// */ +// protected String startAuthentication() throws MOAIDException { +// return startAuthentication("https://localhost:9443/"); +// } +// /** +// * Creates a session using standard parameters, +// * and returns the session ID. +// */ +// protected String startAuthentication(String oaURL) throws MOAIDException { +// String htmlForm = AuthenticationServer.getInstance().startAuthentication( +// "https://localhost:8443/auth", +// "gb", +// null, +// oaURL, +// null, +// null, +// null, +// null, +// null, null); +// String sessionID = parseSessionIDFromForm(htmlForm); +// return sessionID; +// } +// private String parseSessionIDFromForm(String htmlForm) { +// String parName = "MOASessionID="; +// assertTrue( +// "HTML Form enth�lt keine SessionID", +// htmlForm.indexOf(parName) >= 0); +// int i1 = htmlForm.indexOf(parName) + parName.length(); +// int i2 = i1; +// while(i2 < htmlForm.length() && +// (htmlForm.charAt(i2) == '-' || (htmlForm.charAt(i2) >= '0' && htmlForm.charAt(i2) <= '9'))) +// i2++; +// assertTrue("HTML Form enth�lt keine g�ltige SessionID", i2 > i1); +// return htmlForm.substring(i1, i2); +// } +// protected String clearSessionID(String htmlForm) { +// String sessionID = parseSessionIDFromForm(htmlForm); +// int i1 = htmlForm.indexOf(sessionID); +// int i2 = i1 + sessionID.length(); +// return htmlForm.substring(0, i1) + htmlForm.substring(i2); +// } +// protected void assertEqualsIgnoreSessionID(String s1, String s2) { +// String ss1 = clearSessionID(s1); +// String ss2 = clearSessionID(s2); +// assertEquals(ss1, ss2); +// } +// protected void authDataWriter(AuthenticationData authData, String filename) throws Exception +// { +// writeXmldata("AuthenticationDataNEW.xml", clearSamlAssertion(authData.getSamlAssertion()).getBytes("UTF-8")); +// } +// +// /** +// * clearSamlAssertion l�scht aus einer beliebiegen String-Repr�sentation einer XML-Struktur +// * AUSSLIESSLICH die Attribute 'IssueInstant' und 'AssertionID' heraus. +// * @param samlAssertion +// * @return String +// */ +// protected String clearSamlAssertion(String samlAssertion) +// { +// String result = killInclusive(samlAssertion,"IssueInstant='", "'",""); +// result = killInclusive(result,"AssertionID='", "'",""); +// return result; +// } +//}
\ No newline at end of file diff --git a/id/server/idserverlib/src/test/java/test/abnahme/AllTests.java b/id/server/idserverlib/src/test/java/test/abnahme/AllTests.java index b67c62fc0..35dea51a4 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/AllTests.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/AllTests.java @@ -1,73 +1,73 @@ -/* - * 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.abnahme; - -import junit.awtui.TestRunner; -import junit.framework.*; - -import test.abnahme.A.Test100StartAuthentication; -import test.abnahme.A.Test200VerifyIdentityLink; -import test.abnahme.A.Test300VerifyAuthBlock; -import test.abnahme.A.Test400GetAuthenticationData; -import test.abnahme.A.Test500StartAuthenticationServlet; -import test.abnahme.A.Test600GetAuthenticationDataService; -import test.abnahme.A.Test700SelectBKU; -import test.abnahme.C.Test100Konfiguration; -import test.abnahme.P.Test100LoginParameterResolver; - - - - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(Test100StartAuthentication.class); - suite.addTestSuite(Test200VerifyIdentityLink.class); - suite.addTestSuite(Test300VerifyAuthBlock.class); - suite.addTestSuite(Test400GetAuthenticationData.class); - suite.addTestSuite(Test500StartAuthenticationServlet.class); - suite.addTestSuite(Test600GetAuthenticationDataService.class); - suite.addTestSuite(Test700SelectBKU.class); - - suite.addTestSuite(Test100LoginParameterResolver.class); - - suite.addTestSuite(Test100Konfiguration.class); - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +///* +// * 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.abnahme; +// +//import junit.awtui.TestRunner; +//import junit.framework.*; +// +//import test.abnahme.A.Test100StartAuthentication; +//import test.abnahme.A.Test200VerifyIdentityLink; +//import test.abnahme.A.Test300VerifyAuthBlock; +//import test.abnahme.A.Test400GetAuthenticationData; +//import test.abnahme.A.Test500StartAuthenticationServlet; +//import test.abnahme.A.Test600GetAuthenticationDataService; +//import test.abnahme.A.Test700SelectBKU; +//import test.abnahme.C.Test100Konfiguration; +//import test.abnahme.P.Test100LoginParameterResolver; +// +// +// +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AllTests { +// +// public static Test suite() { +// TestSuite suite = new TestSuite(); +// +// suite.addTestSuite(Test100StartAuthentication.class); +// suite.addTestSuite(Test200VerifyIdentityLink.class); +// suite.addTestSuite(Test300VerifyAuthBlock.class); +// suite.addTestSuite(Test400GetAuthenticationData.class); +// suite.addTestSuite(Test500StartAuthenticationServlet.class); +// suite.addTestSuite(Test600GetAuthenticationDataService.class); +// suite.addTestSuite(Test700SelectBKU.class); +// +// suite.addTestSuite(Test100LoginParameterResolver.class); +// +// suite.addTestSuite(Test100Konfiguration.class); +// return suite; +// } +// +// public static void main(String[] args) { +// try { +// TestRunner.run(AllTests.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/C/Test100Konfiguration.java b/id/server/idserverlib/src/test/java/test/abnahme/C/Test100Konfiguration.java index 2ab2071fb..723c1526d 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/C/Test100Konfiguration.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/C/Test100Konfiguration.java @@ -1,84 +1,84 @@ -/* - * 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.abnahme.C; - -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; - -import test.abnahme.AbnahmeTestCase; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ - -public class Test100Konfiguration extends AbnahmeTestCase { - - public Test100Konfiguration(String name) { - super(name); - } - - public void testC001() throws Exception { - try { - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testC002() throws Exception { - try { - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testC003() throws Exception { - try { - System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); - } - catch (Exception e) { - System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); - throw e; - } - } - public void testC051() throws Exception { - try { - // Set moa.id.configuration property - String pathname = findXmldata("ConfigurationC051.xml"); - System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); - System.out.println("Konfiguration " + pathname); - AuthConfigurationProvider.reload(); - } - catch (Exception e) { - System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); - } - // AuthConfigurationProvider.getInstance().getBKUConnectionParameter().getAcceptedServerCertificates() - } -} +///* +// * 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.abnahme.C; +// +//import at.gv.egovernment.moa.id.config.ConfigurationProvider; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +// +//import test.abnahme.AbnahmeTestCase; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ +// +//public class Test100Konfiguration extends AbnahmeTestCase { +// +// public Test100Konfiguration(String name) { +// super(name); +// } +// +// public void testC001() throws Exception { +// try { +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testC002() throws Exception { +// try { +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testC003() throws Exception { +// try { +// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +// } +// catch (Exception e) { +// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +// throw e; +// } +// } +// public void testC051() throws Exception { +// try { +// // Set moa.id.configuration property +// String pathname = findXmldata("ConfigurationC051.xml"); +// System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, pathname); +// System.out.println("Konfiguration " + pathname); +// AuthConfigurationProvider.reload(); +// } +// catch (Exception e) { +// System.out.println("-----------------------Fehler in " + this.getName() + " erfolgreich abgefangen: " + e.getLocalizedMessage() + "-----------------------"); +// } +// // AuthConfigurationProvider.getInstance().getBKUConnectionParameter().getAcceptedServerCertificates() +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/abnahme/P/Test100LoginParameterResolver.java b/id/server/idserverlib/src/test/java/test/abnahme/P/Test100LoginParameterResolver.java index 0e5d88c4d..70b47c938 100644 --- a/id/server/idserverlib/src/test/java/test/abnahme/P/Test100LoginParameterResolver.java +++ b/id/server/idserverlib/src/test/java/test/abnahme/P/Test100LoginParameterResolver.java @@ -1,159 +1,159 @@ -/* - * 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.abnahme.P; -import test.abnahme.AbnahmeTestCase; - -/** - * @author Stefan Knirsch - * @version $Id$ - * - */ - -public class Test100LoginParameterResolver extends AbnahmeTestCase { - -// private static final String CLIENT_IP_ADDRESS = "56.246.75.11"; -// private OAConfiguration oaConf; -// private LoginParameterResolver lpr; +///* +// * 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. +// */ // - public Test100LoginParameterResolver(String name) { - super(name); - } // -// private void setUp(String publicURLPrefix) -// throws Exception { -// -// // get configuration data -// ProxyConfigurationProvider proxyConf = ProxyConfigurationProvider.getInstance(); -// OAProxyParameter oaParam = proxyConf.getOnlineApplicationParameter(publicURLPrefix); -// oaConf = oaParam.getOaConfiguration(); -// System.out.println("Parameterübergabe: " + oaConf.getAuthType()); +//package test.abnahme.P; +//import test.abnahme.AbnahmeTestCase; // -// // get login parameter resolver -// LoginParameterResolverFactory.initialize(); -// lpr = LoginParameterResolverFactory.getLoginParameterResolver(publicURLPrefix); -// } -// public void testP101() throws Exception { -// try { -// // read configuration and set up LoginParameterResolver -// setUp("https://testP101:9443/"); -// if (! oaConf.getAuthType().equals(OAConfiguration.BASIC_AUTH)) -// fail(); -// -// // assemble authentication data -// AuthenticationData authData = new AuthenticationData(); -// authData.setFamilyName("Huber"); -// authData.setGivenName("Hugo"); -// -// // resolve login headers -// Map loginHeaders = lpr.getAuthenticationHeaders(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); -// -// // validate login headers -// assertEquals(1, loginHeaders.keySet().size()); -// System.out.println("Header Authorization: " + loginHeaders.get("Authorization")); -// System.out.println("Decoded UserID:Password " + -// new String(new BASE64Decoder().decodeBuffer(((String)loginHeaders.get("Authorization")).substring(6)))); -// String userIDPassword = "Hugo:Huber"; -// String credentials = Base64Utils.encode(userIDPassword.getBytes()); -// assertEquals("Basic " + credentials, loginHeaders.get("Authorization")); -// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); -// } -// catch (Exception e) { -// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); -// throw e; -// } -// -// } -// public void testP102() throws Exception { -// try { -// // read configuration and set up LoginParameterResolver -// setUp("https://testP102:9443/"); -// if (! oaConf.getAuthType().equals(OAConfiguration.PARAM_AUTH)) -// fail(); -// -// // assemble authentication data -// AuthenticationData authData = new AuthenticationData(); -// String DATE_OF_BIRTH = "1963-12-29"; -// String VPK = "kp6hOq6LRAkLtrqm6EvDm6bMwJw="; -// authData.setDateOfBirth(DATE_OF_BIRTH); -// authData.setBPK(VPK); -// -// // resolve login parameters -// Map loginParameters = lpr.getAuthenticationParameters(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); -// -// // validate login headers -// assertEquals(2, loginParameters.keySet().size()); -// System.out.println("Param1: " + loginParameters.get("Param1")); -// System.out.println("Param2: " + loginParameters.get("Param2")); -// assertEquals(DATE_OF_BIRTH, loginParameters.get("Param1")); -// assertEquals(VPK, loginParameters.get("Param2")); -// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); -// } -// catch (Exception e) { -// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); -// throw e; -// } -// } -// -// public void testP103() throws Exception { -// try { -// // read configuration and set up LoginParameterResolver -// setUp("https://localhost:9443/"); -// if (! oaConf.getAuthType().equals(OAConfiguration.HEADER_AUTH)) -// fail(); -// -// // assemble authentication data -// AuthenticationData authData = new AuthenticationData(); -// boolean PUBLIC_AUTH = true; -// String BKZ = "FinanzamtWien23Leitstelle"; -// boolean QUAL_CERT = false; -// String STAMMZAHL = "3456789012"; -// authData.setPublicAuthority(PUBLIC_AUTH); -// authData.setPublicAuthorityCode(BKZ); -// authData.setQualifiedCertificate(QUAL_CERT); -// authData.setIdentificationValue(STAMMZAHL); +///** +// * @author Stefan Knirsch +// * @version $Id$ +// * +// */ // -// // resolve login headers -// Map loginHeaders = lpr.getAuthenticationHeaders(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); +//public class Test100LoginParameterResolver extends AbnahmeTestCase { // -// // validate login headers -// assertEquals(5, loginHeaders.keySet().size()); -// System.out.println("Header Param1: " + loginHeaders.get("Param1")); -// System.out.println("Header Param2: " + loginHeaders.get("Param2")); -// System.out.println("Header Param3: " + loginHeaders.get("Param3")); -// System.out.println("Header Param4: " + loginHeaders.get("Param4")); -// System.out.println("Header Param5: " + loginHeaders.get("Param5")); -// assertEquals(String.valueOf(PUBLIC_AUTH), loginHeaders.get("Param1")); -// assertEquals(BKZ, loginHeaders.get("Param2")); -// assertEquals(String.valueOf(QUAL_CERT), loginHeaders.get("Param3")); -// assertEquals(STAMMZAHL, loginHeaders.get("Param4")); -// assertEquals(CLIENT_IP_ADDRESS, loginHeaders.get("Param5")); -// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); -// } -// catch (Exception e) { -// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); -// throw e; -// } +//// private static final String CLIENT_IP_ADDRESS = "56.246.75.11"; +//// private OAConfiguration oaConf; +//// private LoginParameterResolver lpr; +//// +// public Test100LoginParameterResolver(String name) { +// super(name); // } -} +//// +//// private void setUp(String publicURLPrefix) +//// throws Exception { +//// +//// // get configuration data +//// ProxyConfigurationProvider proxyConf = ProxyConfigurationProvider.getInstance(); +//// OAProxyParameter oaParam = proxyConf.getOnlineApplicationParameter(publicURLPrefix); +//// oaConf = oaParam.getOaConfiguration(); +//// System.out.println("Parameter�bergabe: " + oaConf.getAuthType()); +//// +//// // get login parameter resolver +//// LoginParameterResolverFactory.initialize(); +//// lpr = LoginParameterResolverFactory.getLoginParameterResolver(publicURLPrefix); +//// } +//// public void testP101() throws Exception { +//// try { +//// // read configuration and set up LoginParameterResolver +//// setUp("https://testP101:9443/"); +//// if (! oaConf.getAuthType().equals(OAConfiguration.BASIC_AUTH)) +//// fail(); +//// +//// // assemble authentication data +//// AuthenticationData authData = new AuthenticationData(); +//// authData.setFamilyName("Huber"); +//// authData.setGivenName("Hugo"); +//// +//// // resolve login headers +//// Map loginHeaders = lpr.getAuthenticationHeaders(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); +//// +//// // validate login headers +//// assertEquals(1, loginHeaders.keySet().size()); +//// System.out.println("Header Authorization: " + loginHeaders.get("Authorization")); +//// System.out.println("Decoded UserID:Password " + +//// new String(new BASE64Decoder().decodeBuffer(((String)loginHeaders.get("Authorization")).substring(6)))); +//// String userIDPassword = "Hugo:Huber"; +//// String credentials = Base64Utils.encode(userIDPassword.getBytes()); +//// assertEquals("Basic " + credentials, loginHeaders.get("Authorization")); +//// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +//// } +//// catch (Exception e) { +//// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +//// throw e; +//// } +//// +//// } +//// public void testP102() throws Exception { +//// try { +//// // read configuration and set up LoginParameterResolver +//// setUp("https://testP102:9443/"); +//// if (! oaConf.getAuthType().equals(OAConfiguration.PARAM_AUTH)) +//// fail(); +//// +//// // assemble authentication data +//// AuthenticationData authData = new AuthenticationData(); +//// String DATE_OF_BIRTH = "1963-12-29"; +//// String VPK = "kp6hOq6LRAkLtrqm6EvDm6bMwJw="; +//// authData.setDateOfBirth(DATE_OF_BIRTH); +//// authData.setBPK(VPK); +//// +//// // resolve login parameters +//// Map loginParameters = lpr.getAuthenticationParameters(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); +//// +//// // validate login headers +//// assertEquals(2, loginParameters.keySet().size()); +//// System.out.println("Param1: " + loginParameters.get("Param1")); +//// System.out.println("Param2: " + loginParameters.get("Param2")); +//// assertEquals(DATE_OF_BIRTH, loginParameters.get("Param1")); +//// assertEquals(VPK, loginParameters.get("Param2")); +//// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +//// } +//// catch (Exception e) { +//// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +//// throw e; +//// } +//// } +//// +//// public void testP103() throws Exception { +//// try { +//// // read configuration and set up LoginParameterResolver +//// setUp("https://localhost:9443/"); +//// if (! oaConf.getAuthType().equals(OAConfiguration.HEADER_AUTH)) +//// fail(); +//// +//// // assemble authentication data +//// AuthenticationData authData = new AuthenticationData(); +//// boolean PUBLIC_AUTH = true; +//// String BKZ = "FinanzamtWien23Leitstelle"; +//// boolean QUAL_CERT = false; +//// String STAMMZAHL = "3456789012"; +//// authData.setPublicAuthority(PUBLIC_AUTH); +//// authData.setPublicAuthorityCode(BKZ); +//// authData.setQualifiedCertificate(QUAL_CERT); +//// authData.setIdentificationValue(STAMMZAHL); +//// +//// // resolve login headers +//// Map loginHeaders = lpr.getAuthenticationHeaders(oaConf, authData, CLIENT_IP_ADDRESS, false, ""); +//// +//// // validate login headers +//// assertEquals(5, loginHeaders.keySet().size()); +//// System.out.println("Header Param1: " + loginHeaders.get("Param1")); +//// System.out.println("Header Param2: " + loginHeaders.get("Param2")); +//// System.out.println("Header Param3: " + loginHeaders.get("Param3")); +//// System.out.println("Header Param4: " + loginHeaders.get("Param4")); +//// System.out.println("Header Param5: " + loginHeaders.get("Param5")); +//// assertEquals(String.valueOf(PUBLIC_AUTH), loginHeaders.get("Param1")); +//// assertEquals(BKZ, loginHeaders.get("Param2")); +//// assertEquals(String.valueOf(QUAL_CERT), loginHeaders.get("Param3")); +//// assertEquals(STAMMZAHL, loginHeaders.get("Param4")); +//// assertEquals(CLIENT_IP_ADDRESS, loginHeaders.get("Param5")); +//// System.out.println("-----------------------Testfall " + this.getName() + " erfolgreich abgearbeitet! -----------------------"); +//// } +//// catch (Exception e) { +//// System.err.println("------ FEHLER IN " + this.getName() + ":" + e.getLocalizedMessage()); +//// throw e; +//// } +//// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/AllTests.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/AllTests.java index fc12ca5e7..98337de6b 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/AllTests.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/AllTests.java @@ -1,65 +1,65 @@ -/* - * 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; - -import test.at.gv.egovernment.moa.id.auth.AuthenticationServerTest; -import test.at.gv.egovernment.moa.id.auth.servlet.GetAuthenticationDataServiceTest; -import test.at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationTest; -import test.at.gv.egovernment.moa.id.config.auth.MOAIDAuthConfigurationProviderTest; -import test.at.gv.egovernment.moa.id.config.proxy.MOAIDProxyConfigurationProviderTest; - -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(AuthenticationServerTest.class); - suite.addTest(test.at.gv.egovernment.moa.id.auth.builder.AllTests.suite()); - suite.addTest(test.at.gv.egovernment.moa.id.auth.parser.AllTests.suite()); - suite.addTestSuite(GetAuthenticationDataServiceTest.class); - suite.addTestSuite(SignatureVerificationTest.class); - suite.addTestSuite(MOAIDAuthConfigurationProviderTest.class); - suite.addTestSuite(MOAIDProxyConfigurationProviderTest.class); - suite.addTest(test.at.gv.egovernment.moa.id.proxy.AllTests.suite()); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +///* +// * 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; +// +//import test.at.gv.egovernment.moa.id.auth.AuthenticationServerTest; +//import test.at.gv.egovernment.moa.id.auth.servlet.GetAuthenticationDataServiceTest; +//import test.at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationTest; +//import test.at.gv.egovernment.moa.id.config.auth.MOAIDAuthConfigurationProviderTest; +//import test.at.gv.egovernment.moa.id.config.proxy.MOAIDProxyConfigurationProviderTest; +// +//import junit.awtui.TestRunner; +//import junit.framework.Test; +//import junit.framework.TestSuite; +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AllTests { +// +// public static Test suite() { +// TestSuite suite = new TestSuite(); +// +// suite.addTestSuite(AuthenticationServerTest.class); +// suite.addTest(test.at.gv.egovernment.moa.id.auth.builder.AllTests.suite()); +// suite.addTest(test.at.gv.egovernment.moa.id.auth.parser.AllTests.suite()); +// suite.addTestSuite(GetAuthenticationDataServiceTest.class); +// suite.addTestSuite(SignatureVerificationTest.class); +// suite.addTestSuite(MOAIDAuthConfigurationProviderTest.class); +// suite.addTestSuite(MOAIDProxyConfigurationProviderTest.class); +// suite.addTest(test.at.gv.egovernment.moa.id.proxy.AllTests.suite()); +// +// return suite; +// } +// +// public static void main(String[] args) { +// try { +// TestRunner.run(AllTests.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java index 187f577a3..c54c31edb 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/AuthenticationServerTest.java @@ -1,80 +1,80 @@ -/* - * 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; - -import java.util.HashMap; - -import at.gv.egovernment.moa.id.auth.AuthenticationServer; -import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; -import at.gv.egovernment.moa.id.data.AuthenticationData; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AuthenticationServerTest extends UnitTestCase { - - public AuthenticationServerTest(String name) { - super(name); - } - - public void testStandard() throws Exception { - doTest( - "standard", - "https://localhost:8443/auth", - "gb", - "https://localhost:9443/", - null, - null); - } - public void doTest(String testdataDirectory, String authURL, String target, String oaURL, String bkuURL, String templateURL) throws Exception { - String testdataRoot = TESTDATA_ROOT + "xmldata/" + testdataDirectory + "/"; - AuthenticationServer server = AuthenticationServer.getInstance(); - String htmlForm = server.startAuthentication(authURL, target, null, oaURL, templateURL, bkuURL, null, null, null, null); - String sessionID = parseSessionIDFromForm(htmlForm); - String infoboxReadResponse = readFile(TESTDATA_ROOT + "xmldata/testperson1/" + "InfoboxReadResponse.xml"); - HashMap parameters = new HashMap(1); - parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); - - String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, parameters); - String createXMLSignatureRequestShould = readFile(testdataRoot + "CreateXMLSignatureRequest.xml"); - assertXmlEquals(createXMLSignatureRequestShould, createXMLSignatureRequest); - String createXMLSignatureResponse = readFile(testdataRoot + "CreateXMLSignatureResponse.xml"); - String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); - AuthenticationData authData = server.getAuthenticationData(samlArtifact); - String authDataShould = readFile(testdataRoot + "AuthenticationDataAssertion.xml"); - assertXmlEquals(authDataShould, authData.getSamlAssertion()); - } - private String parseSessionIDFromForm(String htmlForm) { - String parName = "MOASessionID="; - assertTrue("HTML Form enthält keine SessionID", htmlForm.indexOf(parName) >= 0); - int i1 = htmlForm.indexOf(parName) + parName.length(); - int i2 = htmlForm.indexOf("\"", i1); - assertTrue("HTML Form enthält keine gültige SessionID", i2 > i1); - return htmlForm.substring(i1, i2); - } -} +///* +// * 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; +// +//import java.util.HashMap; +// +//import at.gv.egovernment.moa.id.auth.AuthenticationServer; +//import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +// +//import test.at.gv.egovernment.moa.id.UnitTestCase; +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AuthenticationServerTest extends UnitTestCase { +// +// public AuthenticationServerTest(String name) { +// super(name); +// } +// +// public void testStandard() throws Exception { +// doTest( +// "standard", +// "https://localhost:8443/auth", +// "gb", +// "https://localhost:9443/", +// null, +// null); +// } +// public void doTest(String testdataDirectory, String authURL, String target, String oaURL, String bkuURL, String templateURL) throws Exception { +// String testdataRoot = TESTDATA_ROOT + "xmldata/" + testdataDirectory + "/"; +// AuthenticationServer server = AuthenticationServer.getInstance(); +// String htmlForm = server.startAuthentication(authURL, target, null, oaURL, templateURL, bkuURL, null, null, null, null); +// String sessionID = parseSessionIDFromForm(htmlForm); +// String infoboxReadResponse = readFile(TESTDATA_ROOT + "xmldata/testperson1/" + "InfoboxReadResponse.xml"); +// HashMap parameters = new HashMap(1); +// parameters.put(MOAIDAuthConstants.PARAM_XMLRESPONSE, infoboxReadResponse); +// +// String createXMLSignatureRequest = server.verifyIdentityLink(sessionID, parameters); +// String createXMLSignatureRequestShould = readFile(testdataRoot + "CreateXMLSignatureRequest.xml"); +// assertXmlEquals(createXMLSignatureRequestShould, createXMLSignatureRequest); +// String createXMLSignatureResponse = readFile(testdataRoot + "CreateXMLSignatureResponse.xml"); +// String samlArtifact = server.verifyAuthenticationBlock(sessionID, createXMLSignatureResponse); +// AuthenticationData authData = server.getAuthenticationData(samlArtifact); +// String authDataShould = readFile(testdataRoot + "AuthenticationDataAssertion.xml"); +// assertXmlEquals(authDataShould, authData.getSamlAssertion()); +// } +// private String parseSessionIDFromForm(String htmlForm) { +// String parName = "MOASessionID="; +// assertTrue("HTML Form enth�lt keine SessionID", htmlForm.indexOf(parName) >= 0); +// int i1 = htmlForm.indexOf(parName) + parName.length(); +// int i2 = htmlForm.indexOf("\"", i1); +// assertTrue("HTML Form enth�lt keine g�ltige SessionID", i2 > i1); +// return htmlForm.substring(i1, i2); +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java index 7852dc9cd..166ea1544 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AllTests.java @@ -1,57 +1,57 @@ -/* - * 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 junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author patrick - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - -// suite.addTestSuite(AuthenticationBlockAssertionBuilderTest.class); - suite.addTestSuite(CreateXMLSignatureBuilderTest.class); -// suite.addTestSuite(GetIdentityLinkFormBuilderTest.class); -// suite.addTestSuite(InfoboxReadRequestBuilderTest.class); -// suite.addTestSuite(PersonDataBuilderTest.class); -// suite.addTestSuite(SAMLArtifactBuilderTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +///* +// * 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 junit.awtui.TestRunner; +//import junit.framework.Test; +//import junit.framework.TestSuite; +// +///** +// * @author patrick +// * @version $Id$ +// */ +//public class AllTests { +// +// public static Test suite() { +// TestSuite suite = new TestSuite(); +// +//// suite.addTestSuite(AuthenticationBlockAssertionBuilderTest.class); +// suite.addTestSuite(CreateXMLSignatureBuilderTest.class); +//// suite.addTestSuite(GetIdentityLinkFormBuilderTest.class); +//// suite.addTestSuite(InfoboxReadRequestBuilderTest.class); +//// suite.addTestSuite(PersonDataBuilderTest.class); +//// suite.addTestSuite(SAMLArtifactBuilderTest.class); +// +// return suite; +// } +// +// public static void main(String[] args) { +// try { +// TestRunner.run(AllTests.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java index d369c39bd..b5623bb00 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilderTest.java @@ -1,71 +1,71 @@ -/* - * 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 test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.builder.AuthenticationBlockAssertionBuilder; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AuthenticationBlockAssertionBuilderTest extends UnitTestCase { - private static final String nl = "\n"; - private static final String ISSUER = "Hugo Mustermann"; - private static final String ISSUE_INSTANT = "2003-03-15T22:50:21+01:00"; - private static final String AUTH_URL = "https://auth.moa.gv.at/"; - private static final String TARGET = "Grundbuch"; - private static final String OA_URL = "https://grundbuch.gv.at/"; - private static final String GEB_DAT = "2004-01-02"; - - // wird auch von CreateXMLSignatureBuilderTest verwendet ! - public static final String ASSERTION_SHOULD = -"<saml:Assertion xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' MajorVersion='1' MinorVersion='0' AssertionID='any' Issuer='" + ISSUER + "' IssueInstant='" + ISSUE_INSTANT + "'>" + nl + -" <saml:AttributeStatement>" + nl + -" <saml:Subject>" + nl + -" <saml:NameIdentifier>" + AUTH_URL + "</saml:NameIdentifier>" + nl + -" </saml:Subject>" + nl + -" <saml:Attribute AttributeName='Geschäftsbereich' AttributeNamespace='http://reference.e-government.gv.at/namespace/moa/20020822#'>" + nl + -" <saml:AttributeValue>" + TARGET + "</saml:AttributeValue>" + nl + -" </saml:Attribute>" + nl + -" <saml:Attribute AttributeName='OA' AttributeNamespace='http://reference.e-government.gv.at/namespace/moa/20020822#'>" + nl + -" <saml:AttributeValue>" + OA_URL + "</saml:AttributeValue>" + nl + -" </saml:Attribute>" + nl + -" </saml:AttributeStatement>" + nl + -"</saml:Assertion>"; - - public AuthenticationBlockAssertionBuilderTest(String name) { - super(name); - } - - public void testBuild() throws Exception { - AuthenticationBlockAssertionBuilder builder = new AuthenticationBlockAssertionBuilder(); - String assertionBuilt = builder.buildAuthBlock(ISSUER, ISSUE_INSTANT, AUTH_URL, TARGET, null, "", "", OA_URL, GEB_DAT, null, null); - assertionBuilt = XML_DECL + assertionBuilt; - String assertionShould = XML_DECL + ASSERTION_SHOULD; - assertXmlEquals(assertionShould, assertionBuilt); - } -} +///* +// * 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 test.at.gv.egovernment.moa.id.UnitTestCase; +// +//import at.gv.egovernment.moa.id.auth.builder.AuthenticationBlockAssertionBuilder; +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AuthenticationBlockAssertionBuilderTest extends UnitTestCase { +// private static final String nl = "\n"; +// private static final String ISSUER = "Hugo Mustermann"; +// private static final String ISSUE_INSTANT = "2003-03-15T22:50:21+01:00"; +// private static final String AUTH_URL = "https://auth.moa.gv.at/"; +// private static final String TARGET = "Grundbuch"; +// private static final String OA_URL = "https://grundbuch.gv.at/"; +// private static final String GEB_DAT = "2004-01-02"; +// +// // wird auch von CreateXMLSignatureBuilderTest verwendet ! +// public static final String ASSERTION_SHOULD = +//"<saml:Assertion xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' MajorVersion='1' MinorVersion='0' AssertionID='any' Issuer='" + ISSUER + "' IssueInstant='" + ISSUE_INSTANT + "'>" + nl + +//" <saml:AttributeStatement>" + nl + +//" <saml:Subject>" + nl + +//" <saml:NameIdentifier>" + AUTH_URL + "</saml:NameIdentifier>" + nl + +//" </saml:Subject>" + nl + +//" <saml:Attribute AttributeName='Gesch�ftsbereich' AttributeNamespace='http://reference.e-government.gv.at/namespace/moa/20020822#'>" + nl + +//" <saml:AttributeValue>" + TARGET + "</saml:AttributeValue>" + nl + +//" </saml:Attribute>" + nl + +//" <saml:Attribute AttributeName='OA' AttributeNamespace='http://reference.e-government.gv.at/namespace/moa/20020822#'>" + nl + +//" <saml:AttributeValue>" + OA_URL + "</saml:AttributeValue>" + nl + +//" </saml:Attribute>" + nl + +//" </saml:AttributeStatement>" + nl + +//"</saml:Assertion>"; +// +// public AuthenticationBlockAssertionBuilderTest(String name) { +// super(name); +// } +// +// public void testBuild() throws Exception { +// AuthenticationBlockAssertionBuilder builder = new AuthenticationBlockAssertionBuilder(); +// String assertionBuilt = builder.buildAuthBlock(ISSUER, ISSUE_INSTANT, AUTH_URL, TARGET, null, "", "", OA_URL, GEB_DAT, null, null); +// assertionBuilt = XML_DECL + assertionBuilt; +// String assertionShould = XML_DECL + ASSERTION_SHOULD; +// assertXmlEquals(assertionShould, assertionBuilt); +// } +//} 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 index 87ddaef0c..5b3769c4b 100644 --- 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 @@ -1,129 +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); - } -} +///* +// * 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); +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java index a6b4335db..5d82e00a9 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/parser/AllTests.java @@ -1,53 +1,53 @@ -/* - * 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.parser; - -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(IdentityLinkAssertionParserTest.class); - suite.addTestSuite(SAMLArtifactParserTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +///* +// * 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.parser; +// +//import junit.awtui.TestRunner; +//import junit.framework.Test; +//import junit.framework.TestSuite; +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AllTests { +// +// public static Test suite() { +// TestSuite suite = new TestSuite(); +// +// suite.addTestSuite(IdentityLinkAssertionParserTest.class); +// suite.addTestSuite(SAMLArtifactParserTest.class); +// +// return suite; +// } +// +// public static void main(String[] args) { +// try { +// TestRunner.run(AllTests.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java index ccb8fac7a..f08f5d20f 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/servlet/GetAuthenticationDataServiceTest.java @@ -1,115 +1,115 @@ -/* - * 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.servlet; - -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.auth.servlet.GetAuthenticationDataService; -import at.gv.egovernment.moa.util.Constants; -import at.gv.egovernment.moa.util.DOMUtils; -import at.gv.egovernment.moa.util.XPathUtils; - -/** - * Test case instantiates GetAuthenticationDataService and calls the Request() method. - * It DOES NOT call the web service via Axis. - * - * @author Paul Ivancsics - * @version $Id$ - */ -public class GetAuthenticationDataServiceTest extends UnitTestCase implements Constants { - - private GetAuthenticationDataService service; - - public GetAuthenticationDataServiceTest(String arg0) { - super(arg0); - } - protected void setUp() throws Exception { - service = new GetAuthenticationDataService(); - } - - public void testService2Requests() throws Exception { - String requestString = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + - "<saml:AssertionIDReference>123</saml:AssertionIDReference>" + - "</samlp:Request>"; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request, request})[0]; - assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); - } - public void testServiceNoSAMLArtifact() throws Exception { - String requestString = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + - "<saml:AssertionIDReference>123</saml:AssertionIDReference>" + - "</samlp:Request>"; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", null); - } - public void testService2SAMLArtifacts() throws Exception { - String requestString = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + - "<samlp:AssertionArtifact>123</samlp:AssertionArtifact>" + - "<samlp:AssertionArtifact>456</samlp:AssertionArtifact>" + - "</samlp:Request>"; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); - } - public void testServiceWrongFormat() throws Exception { - String requestString = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + - "</samlp:Request>"; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", null); - } - public void testServiceWrongSAMLArtifact() throws Exception { - String requestString = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + - "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + - "<samlp:AssertionArtifact>WRONGARTIFACT</samlp:AssertionArtifact>" + - "</samlp:Request>"; - Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); - Element response = service.Request(new Element[] {request})[0]; - assertStatus(response, "samlp:Requester", "samlp:ResourceNotRecognized"); - } - private void assertStatus(Element response, String statusCodeShould, String subStatusCodeShould) throws Exception { - Element statusCodeNode = (Element)XPathUtils.selectSingleNode(response, "//samlp:StatusCode"); - String statusCode = statusCodeNode.getAttribute("Value"); - Element subStatusCodeNode = (Element)XPathUtils.selectSingleNode(statusCodeNode, "//samlp:StatusCode/samlp:StatusCode"); - String subStatusCode = subStatusCodeNode == null ? null : subStatusCodeNode.getAttribute("Value"); - System.out.println(statusCode + subStatusCode); - assertEquals(statusCodeShould, statusCode); - assertEquals(subStatusCodeShould, subStatusCode); - } - - -} +///* +// * 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.servlet; +// +//import org.w3c.dom.Element; +// +//import test.at.gv.egovernment.moa.id.UnitTestCase; +// +//import at.gv.egovernment.moa.id.auth.servlet.GetAuthenticationDataService; +//import at.gv.egovernment.moa.util.Constants; +//import at.gv.egovernment.moa.util.DOMUtils; +//import at.gv.egovernment.moa.util.XPathUtils; +// +///** +// * Test case instantiates GetAuthenticationDataService and calls the Request() method. +// * It DOES NOT call the web service via Axis. +// * +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class GetAuthenticationDataServiceTest extends UnitTestCase implements Constants { +// +// private GetAuthenticationDataService service; +// +// public GetAuthenticationDataServiceTest(String arg0) { +// super(arg0); +// } +// protected void setUp() throws Exception { +// service = new GetAuthenticationDataService(); +// } +// +// public void testService2Requests() throws Exception { +// String requestString = +// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + +// "<saml:AssertionIDReference>123</saml:AssertionIDReference>" + +// "</samlp:Request>"; +// Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// Element response = service.Request(new Element[] {request, request})[0]; +// assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); +// } +// public void testServiceNoSAMLArtifact() throws Exception { +// String requestString = +// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + +// "<saml:AssertionIDReference>123</saml:AssertionIDReference>" + +// "</samlp:Request>"; +// Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// Element response = service.Request(new Element[] {request})[0]; +// assertStatus(response, "samlp:Requester", null); +// } +// public void testService2SAMLArtifacts() throws Exception { +// String requestString = +// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + +// "<samlp:AssertionArtifact>123</samlp:AssertionArtifact>" + +// "<samlp:AssertionArtifact>456</samlp:AssertionArtifact>" + +// "</samlp:Request>"; +// Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// Element response = service.Request(new Element[] {request})[0]; +// assertStatus(response, "samlp:Requester", "samlp:TooManyResponses"); +// } +// public void testServiceWrongFormat() throws Exception { +// String requestString = +// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + +// "</samlp:Request>"; +// Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// Element response = service.Request(new Element[] {request})[0]; +// assertStatus(response, "samlp:Requester", null); +// } +// public void testServiceWrongSAMLArtifact() throws Exception { +// String requestString = +// "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + +// "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" RequestID=\"123456\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-02-13T13:59:00\">" + +// "<samlp:AssertionArtifact>WRONGARTIFACT</samlp:AssertionArtifact>" + +// "</samlp:Request>"; +// Element request = DOMUtils.parseDocument(requestString, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); +// Element response = service.Request(new Element[] {request})[0]; +// assertStatus(response, "samlp:Requester", "samlp:ResourceNotRecognized"); +// } +// private void assertStatus(Element response, String statusCodeShould, String subStatusCodeShould) throws Exception { +// Element statusCodeNode = (Element)XPathUtils.selectSingleNode(response, "//samlp:StatusCode"); +// String statusCode = statusCodeNode.getAttribute("Value"); +// Element subStatusCodeNode = (Element)XPathUtils.selectSingleNode(statusCodeNode, "//samlp:StatusCode/samlp:StatusCode"); +// String subStatusCode = subStatusCodeNode == null ? null : subStatusCodeNode.getAttribute("Value"); +// System.out.println(statusCode + subStatusCode); +// assertEquals(statusCodeShould, statusCode); +// assertEquals(subStatusCodeShould, subStatusCode); +// } +// +// +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/auth/MOAIDAuthConfigurationProviderTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/auth/MOAIDAuthConfigurationProviderTest.java index b2b973b4a..780cf55f2 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/auth/MOAIDAuthConfigurationProviderTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/auth/MOAIDAuthConfigurationProviderTest.java @@ -1,136 +1,136 @@ -/* - * 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.config.auth; - -import java.util.Map; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - -import at.gv.egovernment.moa.id.config.ConnectionParameter; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; - -/** - * @author Stefan Knirsch - * @version $Id$ - */ -public class MOAIDAuthConfigurationProviderTest extends UnitTestCase { - private AuthConfigurationProvider provider; - - /** - * Constructor for MOAAuthConfigTest. - * @param name - */ - public MOAIDAuthConfigurationProviderTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - - provider = - new AuthConfigurationProvider(TESTDATA_ROOT + "conf/ConfigurationTest.xml"); - - } - public void testGetTransformsInfoFileNames() { - String[] transformsInfoFileNames; - transformsInfoFileNames = provider.getTransformsInfoFileNames(); -// for (int i = 0; i < transformsInfoFileNames.length; i++) { -// System.out.println( -// "getTransformsInfoFileNames: " + transformsInfoFileNames[i]); - assertEquals(transformsInfoFileNames[0],"http://StringsecLayerTranformsInfo1"); - assertEquals(transformsInfoFileNames[1],"http://StringsecLayerTranformsInfo2"); -// } - - } - - public void testGetMOASPConnectionParameters() { - ConnectionParameter cp; - cp = provider.getMoaSpConnectionParameter(); - assertEquals(cp.getUrl(),"MOA-SP-URL"); - assertEquals(cp.getAcceptedServerCertificates(),"http://AcceptedServerCertificates"); - assertEquals(cp.getClientKeyStorePassword(),"Keystore Pass"); - assertEquals(cp.getClientKeyStore(),"URLtoClientKeystoreAUTH"); -/* System.out.println(); - System.out.println("getMoaSpConnectionParameter :" + cp.getUrl()); - System.out.println( - "getMoaSpConnectionParameter :" + cp.getAcceptedServerCertificates()); - System.out.println( - "getMoaSpConnectionParameter :" + cp.getClientKeyStorePassword()); - System.out.println( - "getMoaSpConnectionParameter :" + cp.getClientKeyStore());*/ - } - public void testGetMoaSpIdentityLinkTrustProfileID() { - - assertEquals(provider.getMoaSpIdentityLinkTrustProfileID(),"StringVerifyIdentiyLinkTrustID"); - - } - public void testGetMoaSpAuthBlockTrustProfileID() { - assertEquals(provider.getMoaSpAuthBlockTrustProfileID(),"StringVerifyAuthBlockTransformID"); - } - - public void testGetMoaSpAuthBlockVerifyTransformsInfoIDs() { - String[] result = provider.getMoaSpAuthBlockVerifyTransformsInfoIDs(); - assertEquals(result[0],"StringVerifyTransformsInfoID1"); - assertEquals(result[1],"StringVerifyTransformsInfoID2"); - - } - - public void testGetOnlineApplicationAuthParameter() { - OAAuthParameter[] result = provider.getOnlineApplicationParameters(); - - assertEquals(result[0].getPublicURLPrefix(),"StringOALoginURL"); - assertEquals(result[0].getProvideStammzahl(),false); - assertEquals(result[0].getProvideAuthBlock(),false); - assertEquals(result[0].getProvideIdentityLink(),false); - - assertEquals(result[1].getPublicURLPrefix(),"StringOALoginURL2"); - assertEquals(result[1].getProvideStammzahl(),true); - assertEquals(result[1].getProvideAuthBlock(),true); - assertEquals(result[1].getProvideIdentityLink(),true); - - -/* for (int i = 0; i < result.length; i++) { - System.out.println(); - System.out.println("getOnlineApplicationParameters Url: " + result[i].getUrl()); - System.out.println("getOnlineApplicationParameters ProvideStammzahl: " + result[i].getProvideStammzahl()); - System.out.println("getOnlineApplicationParameters ProvideAuthBlock: " + result[i].getProvideAuthBlock()); - System.out.println("getOnlineApplicationParameters ProvideIdentityLink: " + result[i].getProvideIdentityLink()); - }*/ - } - - public void testGetGenericConfiguration() { - Map result = provider.getGenericConfiguration(); - assertEquals(result.containsKey("Generic Name 1"),true); - assertEquals(result.containsKey("Generic Name 2"),true); - assertEquals(result.get("Generic Name 1"),"Value1"); - assertEquals(result.get("Generic Name 2"),"Value2"); - /* for (Iterator iter = result.keySet().iterator(); iter.hasNext();) { - String element = (String) iter.next(); - System.out.println("getGenericConfiguration Key:" + element); - System.out.println("getGenericConfiguration Value:" + result.get(element)); - }*/ - } - -} +///* +// * 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.config.auth; +// +//import java.util.Map; +// +//import test.at.gv.egovernment.moa.id.UnitTestCase; +// +//import at.gv.egovernment.moa.id.config.ConnectionParameter; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// */ +//public class MOAIDAuthConfigurationProviderTest extends UnitTestCase { +// private AuthConfigurationProvider provider; +// +// /** +// * Constructor for MOAAuthConfigTest. +// * @param name +// */ +// public MOAIDAuthConfigurationProviderTest(String name) { +// super(name); +// } +// +// protected void setUp() throws Exception { +// +// provider = +// new AuthConfigurationProvider(TESTDATA_ROOT + "conf/ConfigurationTest.xml"); +// +// } +// public void testGetTransformsInfoFileNames() { +// String[] transformsInfoFileNames; +// transformsInfoFileNames = provider.getTransformsInfoFileNames(); +//// for (int i = 0; i < transformsInfoFileNames.length; i++) { +//// System.out.println( +//// "getTransformsInfoFileNames: " + transformsInfoFileNames[i]); +// assertEquals(transformsInfoFileNames[0],"http://StringsecLayerTranformsInfo1"); +// assertEquals(transformsInfoFileNames[1],"http://StringsecLayerTranformsInfo2"); +//// } +// +// } +// +// public void testGetMOASPConnectionParameters() { +// ConnectionParameter cp; +// cp = provider.getMoaSpConnectionParameter(); +// assertEquals(cp.getUrl(),"MOA-SP-URL"); +// assertEquals(cp.getAcceptedServerCertificates(),"http://AcceptedServerCertificates"); +// assertEquals(cp.getClientKeyStorePassword(),"Keystore Pass"); +// assertEquals(cp.getClientKeyStore(),"URLtoClientKeystoreAUTH"); +///* System.out.println(); +// System.out.println("getMoaSpConnectionParameter :" + cp.getUrl()); +// System.out.println( +// "getMoaSpConnectionParameter :" + cp.getAcceptedServerCertificates()); +// System.out.println( +// "getMoaSpConnectionParameter :" + cp.getClientKeyStorePassword()); +// System.out.println( +// "getMoaSpConnectionParameter :" + cp.getClientKeyStore());*/ +// } +// public void testGetMoaSpIdentityLinkTrustProfileID() { +// +// assertEquals(provider.getMoaSpIdentityLinkTrustProfileID(),"StringVerifyIdentiyLinkTrustID"); +// +// } +// public void testGetMoaSpAuthBlockTrustProfileID() { +// assertEquals(provider.getMoaSpAuthBlockTrustProfileID(),"StringVerifyAuthBlockTransformID"); +// } +// +// public void testGetMoaSpAuthBlockVerifyTransformsInfoIDs() { +// String[] result = provider.getMoaSpAuthBlockVerifyTransformsInfoIDs(); +// assertEquals(result[0],"StringVerifyTransformsInfoID1"); +// assertEquals(result[1],"StringVerifyTransformsInfoID2"); +// +// } +// +// public void testGetOnlineApplicationAuthParameter() { +// OAAuthParameter[] result = provider.getOnlineApplicationParameters(); +// +// assertEquals(result[0].getPublicURLPrefix(),"StringOALoginURL"); +// assertEquals(result[0].getProvideStammzahl(),false); +// assertEquals(result[0].getProvideAuthBlock(),false); +// assertEquals(result[0].getProvideIdentityLink(),false); +// +// assertEquals(result[1].getPublicURLPrefix(),"StringOALoginURL2"); +// assertEquals(result[1].getProvideStammzahl(),true); +// assertEquals(result[1].getProvideAuthBlock(),true); +// assertEquals(result[1].getProvideIdentityLink(),true); +// +// +///* for (int i = 0; i < result.length; i++) { +// System.out.println(); +// System.out.println("getOnlineApplicationParameters Url: " + result[i].getUrl()); +// System.out.println("getOnlineApplicationParameters ProvideStammzahl: " + result[i].getProvideStammzahl()); +// System.out.println("getOnlineApplicationParameters ProvideAuthBlock: " + result[i].getProvideAuthBlock()); +// System.out.println("getOnlineApplicationParameters ProvideIdentityLink: " + result[i].getProvideIdentityLink()); +// }*/ +// } +// +// public void testGetGenericConfiguration() { +// Map result = provider.getGenericConfiguration(); +// assertEquals(result.containsKey("Generic Name 1"),true); +// assertEquals(result.containsKey("Generic Name 2"),true); +// assertEquals(result.get("Generic Name 1"),"Value1"); +// assertEquals(result.get("Generic Name 2"),"Value2"); +// /* for (Iterator iter = result.keySet().iterator(); iter.hasNext();) { +// String element = (String) iter.next(); +// System.out.println("getGenericConfiguration Key:" + element); +// System.out.println("getGenericConfiguration Value:" + result.get(element)); +// }*/ +// } +// +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/proxy/MOAIDProxyConfigurationProviderTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/proxy/MOAIDProxyConfigurationProviderTest.java index 64e628e0c..412e35233 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/proxy/MOAIDProxyConfigurationProviderTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/config/proxy/MOAIDProxyConfigurationProviderTest.java @@ -1,151 +1,151 @@ -/* - * 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.config.proxy; - -import java.util.Map; - -import at.gv.egovernment.moa.id.config.ConnectionParameter; -import at.gv.egovernment.moa.id.config.proxy.OAConfiguration; -import at.gv.egovernment.moa.id.config.proxy.ProxyConfigurationProvider; -import at.gv.egovernment.moa.id.config.proxy.OAProxyParameter; - -import test.at.gv.egovernment.moa.id.UnitTestCase; - - - -/** - * @author Stefan Knirsch - * @version $Id$ - */ -public class MOAIDProxyConfigurationProviderTest extends UnitTestCase { - private ProxyConfigurationProvider provider; - - /** - * Constructor for MOAProxyConfigTest. - * @param name - */ - public MOAIDProxyConfigurationProviderTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - - provider = -// new ProxyConfigurationProvider(TESTDATA_ROOT + "conf/ConfigurationTest.xml"); - new ProxyConfigurationProvider("data/deploy/conf/moa-id/ConfigurationTest.xml"); - } - public void testGetAuthComponentConnectionParameter() - { - ConnectionParameter cp; - cp = provider.getAuthComponentConnectionParameter(); - assertEquals(cp.getUrl(),"AuthComponentURL"); - assertEquals( cp.getAcceptedServerCertificates(),"http://www.altova.com"); - assertEquals(cp.getClientKeyStorePassword(),"String"); - assertEquals(cp.getClientKeyStore(),"http://www.altova.com"); - /* System.out.println(); - System.out.println("getProxyComponentConnectionParameter :" + cp.getUrl()); - System.out.println( - "getProxyComponentConnectionParameter :" + cp.getAcceptedServerCertificates()); - System.out.println( - "getProxyComponentConnectionParameter :" + cp.getClientKeyStorePassword()); - System.out.println( - "getProxyComponentConnectionParameter :" + cp.getClientKeyStore());*/ -} - - public void testGetOAProxyParameter() { - OAProxyParameter[] result = provider.getOnlineApplicationParameters(); - - assertEquals("http://localhost:9080/", result[0].getPublicURLPrefix()); - assertEquals("file:data/test/conf/OAConfParamAuth.xml", result[0].getConfigFileURL()); - assertEquals(10, result[0].getSessionTimeOut()); - assertEquals("StringloginParameterResolverImpl1", result[0].getLoginParameterResolverImpl()); - assertEquals("StringconnectionBuilderImpl1", result[0].getConnectionBuilderImpl()); - - assertEquals("ProxyComponentURL", result[0].getConnectionParameter().getUrl()); - assertEquals("url:AcceptedServerCertificates", result[0].getConnectionParameter().getAcceptedServerCertificates()); - assertEquals("URL:toClientKeystoreOA", result[0].getConnectionParameter().getClientKeyStore()); - assertEquals("ClientKeystoreOAPAss", result[0].getConnectionParameter().getClientKeyStorePassword()); - - assertEquals("StringOALoginURL2", result[1].getPublicURLPrefix()); - assertEquals("file:data/test/conf/OAConfHeaderAuth.xml", result[1].getConfigFileURL()); - assertEquals(20, result[1].getSessionTimeOut()); - assertEquals("StringloginParameterResolverImpl2",result[1].getLoginParameterResolverImpl()); - assertEquals("StringconnectionBuilderImpl2", result[1].getConnectionBuilderImpl()); - - assertEquals("ProxyComponentURL2", result[1].getConnectionParameter().getUrl()); - assertEquals("url:AcceptedServerCertificates2", result[1].getConnectionParameter().getAcceptedServerCertificates()); - assertEquals("URL:toClientKeystoreOA2", result[1].getConnectionParameter().getClientKeyStore()); - assertEquals("ClientKeystoreOAPAss2", result[1].getConnectionParameter().getClientKeyStorePassword()); - - assertEquals("StringOALoginURL3", result[2].getPublicURLPrefix()); - assertEquals("file:data/test/conf/OAConfBasicAuth.xml", result[2].getConfigFileURL()); - assertEquals(20, result[2].getSessionTimeOut()); - assertEquals("StringloginParameterResolverImpl3",result[2].getLoginParameterResolverImpl()); - assertEquals("StringconnectionBuilderImpl3", result[2].getConnectionBuilderImpl()); - - assertEquals("ProxyComponentURL3", result[2].getConnectionParameter().getUrl()); - assertEquals("url:AcceptedServerCertificates3", result[2].getConnectionParameter().getAcceptedServerCertificates()); - assertEquals("URL:toClientKeystoreOA3", result[2].getConnectionParameter().getClientKeyStore()); - assertEquals("ClientKeystoreOAPAss3", result[2].getConnectionParameter().getClientKeyStorePassword()); - } - - public void testGetGenericConfiguration() { - Map result = provider.getGenericConfiguration(); - assertEquals(true, result.containsKey("authenticationSessionTimeOut")); - assertEquals(true, result.containsKey("authenticationDataTimeOut")); - assertEquals("600", result.get("authenticationSessionTimeOut")); - assertEquals("120", result.get("authenticationDataTimeOut")); - } - - public void testOAConfigurationProvider() throws Exception - { - OAProxyParameter[] result = provider.getOnlineApplicationParameters(); - // für jeden Parameter müsste theoretisch bereits ein Provider instanziiert worden sein, - // aus diesem Grund braucht man NICHT mehr die File-URL anzugeben, PublicURLPrefix reicht - - // sollte ParamAuth sein - OAConfiguration oac1 = result[0].getOaConfiguration(); - assertEquals(OAConfiguration.PARAM_AUTH, oac1.getAuthType()); - assertEquals("MOADateOfBirth", oac1.getParamAuthMapping().get("Param1")); - assertEquals("MOABPK", oac1.getParamAuthMapping().get("Param2")); - // sollte HeaderAuth sein - OAConfiguration oac2 = result[1].getOaConfiguration(); - assertEquals(OAConfiguration.HEADER_AUTH, oac2.getAuthType()); - assertEquals("MOAPublicAuthority", oac2.getHeaderAuthMapping().get("Param1")); - assertEquals("MOABKZ", oac2.getHeaderAuthMapping().get("Param2")); - assertEquals("MOAQualifiedCertificate", oac2.getHeaderAuthMapping().get("Param3")); - assertEquals("MOAStammzahl", oac2.getHeaderAuthMapping().get("Param4")); - assertEquals("MOAIPAddress", oac2.getHeaderAuthMapping().get("Param5")); - - // sollte BasicAuth sein - OAConfiguration oac3 = result[2].getOaConfiguration(); - assertEquals(OAConfiguration.BASIC_AUTH, oac3.getAuthType()); - assertEquals("MOAGivenName", oac3.getBasicAuthUserIDMapping()); - assertEquals("MOAFamilyName", oac3.getBasicAuthPasswordMapping()); - //Fehlerfall: - - - } -} +///* +// * 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.config.proxy; +// +//import java.util.Map; +// +//import at.gv.egovernment.moa.id.config.ConnectionParameter; +//import at.gv.egovernment.moa.id.config.proxy.OAConfiguration; +//import at.gv.egovernment.moa.id.config.proxy.ProxyConfigurationProvider; +//import at.gv.egovernment.moa.id.config.proxy.OAProxyParameter; +// +//import test.at.gv.egovernment.moa.id.UnitTestCase; +// +// +// +///** +// * @author Stefan Knirsch +// * @version $Id$ +// */ +//public class MOAIDProxyConfigurationProviderTest extends UnitTestCase { +// private ProxyConfigurationProvider provider; +// +// /** +// * Constructor for MOAProxyConfigTest. +// * @param name +// */ +// public MOAIDProxyConfigurationProviderTest(String name) { +// super(name); +// } +// +// protected void setUp() throws Exception { +// +// provider = +//// new ProxyConfigurationProvider(TESTDATA_ROOT + "conf/ConfigurationTest.xml"); +// new ProxyConfigurationProvider("data/deploy/conf/moa-id/ConfigurationTest.xml"); +// } +// public void testGetAuthComponentConnectionParameter() +// { +// ConnectionParameter cp; +// cp = provider.getAuthComponentConnectionParameter(); +// assertEquals(cp.getUrl(),"AuthComponentURL"); +// assertEquals( cp.getAcceptedServerCertificates(),"http://www.altova.com"); +// assertEquals(cp.getClientKeyStorePassword(),"String"); +// assertEquals(cp.getClientKeyStore(),"http://www.altova.com"); +// /* System.out.println(); +// System.out.println("getProxyComponentConnectionParameter :" + cp.getUrl()); +// System.out.println( +// "getProxyComponentConnectionParameter :" + cp.getAcceptedServerCertificates()); +// System.out.println( +// "getProxyComponentConnectionParameter :" + cp.getClientKeyStorePassword()); +// System.out.println( +// "getProxyComponentConnectionParameter :" + cp.getClientKeyStore());*/ +//} +// +// public void testGetOAProxyParameter() { +// OAProxyParameter[] result = provider.getOnlineApplicationParameters(); +// +// assertEquals("http://localhost:9080/", result[0].getPublicURLPrefix()); +// assertEquals("file:data/test/conf/OAConfParamAuth.xml", result[0].getConfigFileURL()); +// assertEquals(10, result[0].getSessionTimeOut()); +// assertEquals("StringloginParameterResolverImpl1", result[0].getLoginParameterResolverImpl()); +// assertEquals("StringconnectionBuilderImpl1", result[0].getConnectionBuilderImpl()); +// +// assertEquals("ProxyComponentURL", result[0].getConnectionParameter().getUrl()); +// assertEquals("url:AcceptedServerCertificates", result[0].getConnectionParameter().getAcceptedServerCertificates()); +// assertEquals("URL:toClientKeystoreOA", result[0].getConnectionParameter().getClientKeyStore()); +// assertEquals("ClientKeystoreOAPAss", result[0].getConnectionParameter().getClientKeyStorePassword()); +// +// assertEquals("StringOALoginURL2", result[1].getPublicURLPrefix()); +// assertEquals("file:data/test/conf/OAConfHeaderAuth.xml", result[1].getConfigFileURL()); +// assertEquals(20, result[1].getSessionTimeOut()); +// assertEquals("StringloginParameterResolverImpl2",result[1].getLoginParameterResolverImpl()); +// assertEquals("StringconnectionBuilderImpl2", result[1].getConnectionBuilderImpl()); +// +// assertEquals("ProxyComponentURL2", result[1].getConnectionParameter().getUrl()); +// assertEquals("url:AcceptedServerCertificates2", result[1].getConnectionParameter().getAcceptedServerCertificates()); +// assertEquals("URL:toClientKeystoreOA2", result[1].getConnectionParameter().getClientKeyStore()); +// assertEquals("ClientKeystoreOAPAss2", result[1].getConnectionParameter().getClientKeyStorePassword()); +// +// assertEquals("StringOALoginURL3", result[2].getPublicURLPrefix()); +// assertEquals("file:data/test/conf/OAConfBasicAuth.xml", result[2].getConfigFileURL()); +// assertEquals(20, result[2].getSessionTimeOut()); +// assertEquals("StringloginParameterResolverImpl3",result[2].getLoginParameterResolverImpl()); +// assertEquals("StringconnectionBuilderImpl3", result[2].getConnectionBuilderImpl()); +// +// assertEquals("ProxyComponentURL3", result[2].getConnectionParameter().getUrl()); +// assertEquals("url:AcceptedServerCertificates3", result[2].getConnectionParameter().getAcceptedServerCertificates()); +// assertEquals("URL:toClientKeystoreOA3", result[2].getConnectionParameter().getClientKeyStore()); +// assertEquals("ClientKeystoreOAPAss3", result[2].getConnectionParameter().getClientKeyStorePassword()); +// } +// +// public void testGetGenericConfiguration() { +// Map result = provider.getGenericConfiguration(); +// assertEquals(true, result.containsKey("authenticationSessionTimeOut")); +// assertEquals(true, result.containsKey("authenticationDataTimeOut")); +// assertEquals("600", result.get("authenticationSessionTimeOut")); +// assertEquals("120", result.get("authenticationDataTimeOut")); +// } +// +// public void testOAConfigurationProvider() throws Exception +// { +// OAProxyParameter[] result = provider.getOnlineApplicationParameters(); +// // f�r jeden Parameter m�sste theoretisch bereits ein Provider instanziiert worden sein, +// // aus diesem Grund braucht man NICHT mehr die File-URL anzugeben, PublicURLPrefix reicht +// +// // sollte ParamAuth sein +// OAConfiguration oac1 = result[0].getOaConfiguration(); +// assertEquals(OAConfiguration.PARAM_AUTH, oac1.getAuthType()); +// assertEquals("MOADateOfBirth", oac1.getParamAuthMapping().get("Param1")); +// assertEquals("MOABPK", oac1.getParamAuthMapping().get("Param2")); +// // sollte HeaderAuth sein +// OAConfiguration oac2 = result[1].getOaConfiguration(); +// assertEquals(OAConfiguration.HEADER_AUTH, oac2.getAuthType()); +// assertEquals("MOAPublicAuthority", oac2.getHeaderAuthMapping().get("Param1")); +// assertEquals("MOABKZ", oac2.getHeaderAuthMapping().get("Param2")); +// assertEquals("MOAQualifiedCertificate", oac2.getHeaderAuthMapping().get("Param3")); +// assertEquals("MOAStammzahl", oac2.getHeaderAuthMapping().get("Param4")); +// assertEquals("MOAIPAddress", oac2.getHeaderAuthMapping().get("Param5")); +// +// // sollte BasicAuth sein +// OAConfiguration oac3 = result[2].getOaConfiguration(); +// assertEquals(OAConfiguration.BASIC_AUTH, oac3.getAuthType()); +// assertEquals("MOAGivenName", oac3.getBasicAuthUserIDMapping()); +// assertEquals("MOAFamilyName", oac3.getBasicAuthPasswordMapping()); +// //Fehlerfall: +// +// +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/proxy/AllTests.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/proxy/AllTests.java index 84e41e12e..76b0c936a 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/proxy/AllTests.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/proxy/AllTests.java @@ -1,55 +1,55 @@ -/* - * 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.proxy; - -import test.at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilderTest; -import test.at.gv.egovernment.moa.id.proxy.parser.SAMLResponseParserTest; -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(SAMLRequestBuilderTest.class); - suite.addTestSuite(SAMLResponseParserTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +///* +// * 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.proxy; +// +//import test.at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilderTest; +//import test.at.gv.egovernment.moa.id.proxy.parser.SAMLResponseParserTest; +//import junit.awtui.TestRunner; +//import junit.framework.Test; +//import junit.framework.TestSuite; +// +///** +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class AllTests { +// +// public static Test suite() { +// TestSuite suite = new TestSuite(); +// +// suite.addTestSuite(SAMLRequestBuilderTest.class); +// suite.addTestSuite(SAMLResponseParserTest.class); +// +// return suite; +// } +// +// public static void main(String[] args) { +// try { +// TestRunner.run(AllTests.class); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +//} diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/util/SSLUtilsTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/util/SSLUtilsTest.java index 19ad228a4..db6a0ac63 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/util/SSLUtilsTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/util/SSLUtilsTest.java @@ -1,116 +1,116 @@ -/* - * 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.util; - -import iaik.pki.jsse.IAIKX509TrustManager; - -import java.net.URL; -import java.security.Security; - -import javax.net.ssl.SSLException; -import javax.net.ssl.SSLSocketFactory; - -import com.sun.net.ssl.HttpsURLConnection; - -import at.gv.egovernment.moa.id.config.ConfigurationProvider; -import at.gv.egovernment.moa.id.config.ConnectionParameter; -import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; -import at.gv.egovernment.moa.id.config.proxy.OAProxyParameter; -import at.gv.egovernment.moa.id.config.proxy.ProxyConfigurationProvider; -import at.gv.egovernment.moa.id.iaik.config.LoggerConfigImpl; -import at.gv.egovernment.moa.id.util.SSLUtils; -import test.at.gv.egovernment.moa.id.UnitTestCase; - -/* - * @author Paul Ivancsics - * @version $Id$ - */ -public class SSLUtilsTest extends UnitTestCase { - - public SSLUtilsTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - //System.setProperty("javax.net.debug", "all"); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); - IAIKX509TrustManager.initLog(new LoggerConfigImpl("file:" + TESTDATA_ROOT + "conf/log4j.properties")); - System.setProperty("https.cipherSuites", "SSL_DHE_DSS_WITH_DES_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,SSL_RSA_WITH_DES_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_EXPORT_WITH_RC4_40_MD5"); - } - - public void testVerisignOK() throws Exception { - doTestOA("conf/ConfigurationTest.xml", "http://verisign.moa.gv.at/", true, null); - } - public void testATrustOK() throws Exception { - doTestOA("conf/ConfigurationTest.xml", "http://a-trust.moa.gv.at/", true, null); - } - public void testBaltimoreOK() throws Exception { - doTestOA("conf/ConfigurationTest.xml", "http://baltimore.moa.gv.at/", true, null); - } - public void testCIOOK() throws Exception { - doTestOA("conf/ConfigurationTest.xml", "http://cio.moa.gv.at/", true, null); - } - public void testMOASPOK() throws Exception { - System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, - TESTDATA_ROOT + "conf/ConfigurationTest.xml"); - ConnectionParameter connParam = AuthConfigurationProvider.getInstance().getMoaSpConnectionParameter(); - doTest(connParam, true, null); - } - private void doTestOA(String configFile, String publicURLPrefix, boolean shouldOK, String exMessageFragment) throws Exception { - System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, - TESTDATA_ROOT + configFile); - ProxyConfigurationProvider proxyConf = - ProxyConfigurationProvider.getInstance(); - OAProxyParameter oaParam = proxyConf.getOnlineApplicationParameter(publicURLPrefix); - ConnectionParameter connParam = oaParam.getConnectionParameter(); - doTest(connParam, shouldOK, exMessageFragment); - } - private void doTest(ConnectionParameter connParam, boolean shouldOK, String exMessageFragment) throws Exception { - SSLUtils.initialize(); - AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); - SSLSocketFactory ssf = SSLUtils.getSSLSocketFactory(authConf, connParam); - URL url = new URL(connParam.getUrl()); - HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); - conn.setRequestMethod("GET"); - conn.setDoInput(true); - conn.setDoOutput(true); - conn.setUseCaches(false); - conn.setAllowUserInteraction(false); - conn.setSSLSocketFactory(ssf); - try { - conn.connect(); - assertTrue(shouldOK); - assertEquals(200, conn.getResponseCode()); - conn.disconnect(); - } - catch (SSLException ex) { - ex.printStackTrace(); - assertFalse(shouldOK); - assertTrue(ex.getMessage().indexOf(exMessageFragment) >= 0); - } - } - -} +///* +// * 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.util; +// +//import iaik.pki.jsse.IAIKX509TrustManager; +// +//import java.net.URL; +//import java.security.Security; +// +//import javax.net.ssl.SSLException; +//import javax.net.ssl.SSLSocketFactory; +// +//import com.sun.net.ssl.HttpsURLConnection; +// +//import at.gv.egovernment.moa.id.config.ConfigurationProvider; +//import at.gv.egovernment.moa.id.config.ConnectionParameter; +//import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; +//import at.gv.egovernment.moa.id.config.proxy.OAProxyParameter; +//import at.gv.egovernment.moa.id.config.proxy.ProxyConfigurationProvider; +//import at.gv.egovernment.moa.id.iaik.config.LoggerConfigImpl; +//import at.gv.egovernment.moa.id.util.SSLUtils; +//import test.at.gv.egovernment.moa.id.UnitTestCase; +// +///* +// * @author Paul Ivancsics +// * @version $Id$ +// */ +//public class SSLUtilsTest extends UnitTestCase { +// +// public SSLUtilsTest(String name) { +// super(name); +// } +// +// protected void setUp() throws Exception { +// //System.setProperty("javax.net.debug", "all"); +// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); +// System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); +// IAIKX509TrustManager.initLog(new LoggerConfigImpl("file:" + TESTDATA_ROOT + "conf/log4j.properties")); +// System.setProperty("https.cipherSuites", "SSL_DHE_DSS_WITH_DES_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,SSL_RSA_WITH_DES_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_EXPORT_WITH_RC4_40_MD5"); +// } +// +// public void testVerisignOK() throws Exception { +// doTestOA("conf/ConfigurationTest.xml", "http://verisign.moa.gv.at/", true, null); +// } +// public void testATrustOK() throws Exception { +// doTestOA("conf/ConfigurationTest.xml", "http://a-trust.moa.gv.at/", true, null); +// } +// public void testBaltimoreOK() throws Exception { +// doTestOA("conf/ConfigurationTest.xml", "http://baltimore.moa.gv.at/", true, null); +// } +// public void testCIOOK() throws Exception { +// doTestOA("conf/ConfigurationTest.xml", "http://cio.moa.gv.at/", true, null); +// } +// public void testMOASPOK() throws Exception { +// System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, +// TESTDATA_ROOT + "conf/ConfigurationTest.xml"); +// ConnectionParameter connParam = AuthConfigurationProvider.getInstance().getMoaSpConnectionParameter(); +// doTest(connParam, true, null); +// } +// private void doTestOA(String configFile, String publicURLPrefix, boolean shouldOK, String exMessageFragment) throws Exception { +// System.setProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME, +// TESTDATA_ROOT + configFile); +// ProxyConfigurationProvider proxyConf = +// ProxyConfigurationProvider.getInstance(); +// OAProxyParameter oaParam = proxyConf.getOnlineApplicationParameter(publicURLPrefix); +// ConnectionParameter connParam = oaParam.getConnectionParameter(); +// doTest(connParam, shouldOK, exMessageFragment); +// } +// private void doTest(ConnectionParameter connParam, boolean shouldOK, String exMessageFragment) throws Exception { +// SSLUtils.initialize(); +// AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); +// SSLSocketFactory ssf = SSLUtils.getSSLSocketFactory(authConf, connParam); +// URL url = new URL(connParam.getUrl()); +// HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); +// conn.setRequestMethod("GET"); +// conn.setDoInput(true); +// conn.setDoOutput(true); +// conn.setUseCaches(false); +// conn.setAllowUserInteraction(false); +// conn.setSSLSocketFactory(ssf); +// try { +// conn.connect(); +// assertTrue(shouldOK); +// assertEquals(200, conn.getResponseCode()); +// conn.disconnect(); +// } +// catch (SSLException ex) { +// ex.printStackTrace(); +// assertFalse(shouldOK); +// assertTrue(ex.getMessage().indexOf(exMessageFragment) >= 0); +// } +// } +// +//} diff --git a/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java b/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java index 67504fa47..50854e3e5 100644 --- a/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java +++ b/id/server/idserverlib/src/test/java/test/tlenz/simpletest.java @@ -1,77 +1,77 @@ -package test.tlenz; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Date; -import java.util.Properties; - -import org.hibernate.cfg.Configuration; - -import at.gv.egovernment.moa.id.commons.db.HibernateUtil; -import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore; -import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; -import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.storage.AssertionStorage; -import at.gv.egovernment.moa.util.MiscUtil; - -public class simpletest { - - public static void main(String[] args) { - - System.setProperty("mandates.configuration", "D:/Projekte/svn/moa-id/moa-id.properties"); - String propertiesFileLocation = System.getProperty("mandates.configuration"); - - MiscUtil.assertNotNull(propertiesFileLocation, "propertiesFileName"); - File propertiesFile = new File(propertiesFileLocation); - FileInputStream fis; - try { - fis = new FileInputStream(propertiesFile); - } catch (FileNotFoundException e) { - - e.printStackTrace(); - return; - } - - Properties props = new Properties(); - try { - props.load(fis); - } catch (IOException e) { - - e.printStackTrace(); - return; - } - - // initialize hibernate - synchronized (simpletest.class) { - - - Configuration hibernateConfig = new Configuration(); - hibernateConfig.addAnnotatedClass(AssertionStore.class); - hibernateConfig.addProperties(props); - HibernateUtil.initHibernate(hibernateConfig, props); - } - - AssertionStorage store = new AssertionStorage(); +//package test.tlenz; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.util.Date; +//import java.util.Properties; +// +//import org.hibernate.cfg.Configuration; +// +//import at.gv.egovernment.moa.id.commons.db.HibernateUtil; +//import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore; +//import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; +//import at.gv.egovernment.moa.id.data.AuthenticationData; +//import at.gv.egovernment.moa.id.storage.AssertionStorage; +//import at.gv.egovernment.moa.util.MiscUtil; +// +//public class simpletest { +// +// public static void main(String[] args) { // -// AuthenticationData assertion = new AuthenticationData(); -// assertion.setBPK("bPK_schaut_anders_aus"); +// System.setProperty("mandates.configuration", "D:/Projekte/svn/moa-id/moa-id.properties"); +// String propertiesFileLocation = System.getProperty("mandates.configuration"); // -// //store.put("test", assertion ); - - - store.clean(new Date().getTime(), 1000); - +// MiscUtil.assertNotNull(propertiesFileLocation, "propertiesFileName"); +// File propertiesFile = new File(propertiesFileLocation); +// FileInputStream fis; // try { -// AuthenticationData test = (AuthenticationData) store.get("test"); -// -// } catch (MOADatabaseException e) { -// // TODO Auto-generated catch block +// fis = new FileInputStream(propertiesFile); +// } catch (FileNotFoundException e) { +// // e.printStackTrace(); +// return; // } - - - - } -} +// +// Properties props = new Properties(); +// try { +// props.load(fis); +// } catch (IOException e) { +// +// e.printStackTrace(); +// return; +// } +// +// // initialize hibernate +// synchronized (simpletest.class) { +// +// +// Configuration hibernateConfig = new Configuration(); +// hibernateConfig.addAnnotatedClass(AssertionStore.class); +// hibernateConfig.addProperties(props); +// HibernateUtil.initHibernate(hibernateConfig, props); +// } +// +// AssertionStorage store = new AssertionStorage(); +//// +//// AuthenticationData assertion = new AuthenticationData(); +//// assertion.setBPK("bPK_schaut_anders_aus"); +//// +//// //store.put("test", assertion ); +// +// +// store.clean(new Date().getTime(), 1000); +// +//// try { +//// AuthenticationData test = (AuthenticationData) store.get("test"); +//// +//// } catch (MOADatabaseException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +// +// +// +// } +//} |