aboutsummaryrefslogtreecommitdiff
path: root/id.server/src/test/abnahme/P
diff options
context:
space:
mode:
authorrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-10-24 08:34:56 +0000
committerrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-10-24 08:34:56 +0000
commitdd45e938564249a5e6897bd92dd29808d8990868 (patch)
tree372d8a4b128cff09262ad09d6a4cf5765d672d61 /id.server/src/test/abnahme/P
parent59f78a67d7357fd31de68fc2b623f95b3d654ebc (diff)
downloadmoa-id-spss-dd45e938564249a5e6897bd92dd29808d8990868.tar.gz
moa-id-spss-dd45e938564249a5e6897bd92dd29808d8990868.tar.bz2
moa-id-spss-dd45e938564249a5e6897bd92dd29808d8990868.zip
MOA-ID version 1.1 (initial)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@19 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'id.server/src/test/abnahme/P')
-rw-r--r--id.server/src/test/abnahme/P/Test100LoginParameterResolver.java146
1 files changed, 146 insertions, 0 deletions
diff --git a/id.server/src/test/abnahme/P/Test100LoginParameterResolver.java b/id.server/src/test/abnahme/P/Test100LoginParameterResolver.java
new file mode 100644
index 000000000..8b7b2002f
--- /dev/null
+++ b/id.server/src/test/abnahme/P/Test100LoginParameterResolver.java
@@ -0,0 +1,146 @@
+package test.abnahme.P;
+import java.util.Map;
+
+import sun.misc.BASE64Decoder;
+import test.abnahme.AbnahmeTestCase;
+
+import at.gv.egovernment.moa.id.config.proxy.OAConfiguration;
+import at.gv.egovernment.moa.id.config.proxy.OAProxyParameter;
+import at.gv.egovernment.moa.id.config.proxy.ProxyConfigurationProvider;
+import at.gv.egovernment.moa.id.data.AuthenticationData;
+import at.gv.egovernment.moa.id.proxy.LoginParameterResolver;
+import at.gv.egovernment.moa.id.proxy.LoginParameterResolverFactory;
+import at.gv.egovernment.moa.util.Base64Utils;
+
+/**
+ * @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;
+
+ 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);
+
+ // 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.setVPK(VPK);
+
+ // resolve login parameters
+ Map loginParameters = lpr.getAuthenticationParameters(oaConf, authData, CLIENT_IP_ADDRESS);
+
+ // 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 ZMR_ZAHL = "3456789012";
+ authData.setPublicAuthority(PUBLIC_AUTH);
+ authData.setPublicAuthorityCode(BKZ);
+ authData.setQualifiedCertificate(QUAL_CERT);
+ authData.setIdentificationValue(ZMR_ZAHL);
+
+ // resolve login headers
+ Map loginHeaders = lpr.getAuthenticationHeaders(oaConf, authData, CLIENT_IP_ADDRESS);
+
+ // 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(ZMR_ZAHL, 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;
+ }
+ }
+}