diff options
Diffstat (limited to 'id/server/modules/moa-id-module-sl20_authentication/src/test/java')
3 files changed, 72 insertions, 33 deletions
diff --git a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_ATrust.java b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_ATrust.java index c3c10dd16..6ebbd0704 100644 --- a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_ATrust.java +++ b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_ATrust.java @@ -5,11 +5,8 @@ import java.io.InputStreamReader; import org.apache.commons.io.IOUtils; import org.junit.Before; -import org.junit.runner.RunWith; -import org.opensaml.DefaultBootstrap; import org.opensaml.xml.ConfigurationException; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -17,12 +14,12 @@ import com.google.gson.JsonParser; import at.gv.egovernment.moa.id.auth.modules.sl20_auth.exceptions.SLCommandoParserException; import at.gv.egovernment.moa.id.auth.modules.sl20_auth.sl20.SL20JSONExtractorUtils; -@RunWith(SpringJUnit4ClassRunner.class) +//@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/SpringTest-context.xml") public class EIDDataVerifier_ATrust extends eIDDataVerifierTest { @Before - public void init() throws SLCommandoParserException, IOException, ConfigurationException { + public void init() throws SLCommandoParserException, IOException, ConfigurationException, at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException { String eIDDataString = IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream("/tests/eIDdata_atrust.json"))); JsonParser jsonParser = new JsonParser(); JsonObject qualeIDResult = jsonParser.parse(eIDDataString).getAsJsonObject(); @@ -35,8 +32,6 @@ public class EIDDataVerifier_ATrust extends eIDDataVerifierTest { if (eIDData == null || eIDData.isEmpty()) throw new SLCommandoParserException("Can not load eID data"); - DefaultBootstrap.bootstrap(); - } @Override diff --git a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_OwnTest.java b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_OwnTest.java index e56d5834a..419142c7d 100644 --- a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_OwnTest.java +++ b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/EIDDataVerifier_OwnTest.java @@ -6,7 +6,6 @@ import java.io.InputStreamReader; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.runner.RunWith; -import org.opensaml.DefaultBootstrap; import org.opensaml.xml.ConfigurationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -23,7 +22,7 @@ import at.gv.egovernment.moa.id.auth.modules.sl20_auth.sl20.SL20JSONExtractorUti public class EIDDataVerifier_OwnTest extends eIDDataVerifierTest { @Before - public void init() throws SLCommandoParserException, IOException, ConfigurationException { + public void init() throws SLCommandoParserException, IOException, ConfigurationException, at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException { String eIDDataString = IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream("/tests/eIDdata_own_test.json"))); JsonParser jsonParser = new JsonParser(); JsonElement payLoad = jsonParser.parse(eIDDataString).getAsJsonObject(); @@ -33,12 +32,12 @@ public class EIDDataVerifier_OwnTest extends eIDDataVerifierTest { if (eIDData == null || eIDData.isEmpty()) throw new SLCommandoParserException("Can not load eID data"); - DefaultBootstrap.bootstrap(); } @Override protected String getSl20ReqId() { return "_57010b7fcc93cc4cf3f2b764389137c2"; } + } diff --git a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/eIDDataVerifierTest.java b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/eIDDataVerifierTest.java index 365152f66..32d623b88 100644 --- a/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/eIDDataVerifierTest.java +++ b/id/server/modules/moa-id-module-sl20_authentication/src/test/java/at/gv/egovernment/moa/id/auth/modules/sl20_auth/eIDDataVerifierTest.java @@ -1,9 +1,12 @@ package at.gv.egovernment.moa.id.auth.modules.sl20_auth; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.Map; +import org.junit.BeforeClass; import org.junit.Test; +import org.opensaml.DefaultBootstrap; import org.opensaml.saml2.core.Assertion; import at.gv.egovernment.moa.id.auth.modules.sl20_auth.dummydata.DummyAuthConfig; @@ -30,13 +33,41 @@ import iaik.security.provider.IAIK; public abstract class eIDDataVerifierTest { protected Map<String, String> eIDData = null; + + + + @BeforeClass + public static void moaSPSSInitialize() throws ConfigurationException, org.opensaml.xml.ConfigurationException, IOException { + Logger.info("Loading Java security providers."); + //System.setProperty("moa.spss.server.configuration", "F:\\Projekte\\configs\\moa-spss\\MOASPSSConfiguration.xml"); + String current = new java.io.File( "." ).getCanonicalPath(); + System.setProperty("moa.spss.server.configuration", current + "\\src\\test\\resources\\moaspss_config\\MOASPSSConfiguration.xml"); + IAIK.addAsProvider(); + ECCelerate.addAsProvider(); + DefaultBootstrap.bootstrap(); + + try { + LoggingContextManager.getInstance().setLoggingContext( + new LoggingContext("startup")); + Logger.debug("Starting MOA-SPSS initialization process ... "); + Configurator.getInstance().init(); + Logger.info("MOA-SPSS initialization complete "); + + } catch (MOAException e) { + Logger.error("MOA-SP initialization FAILED!", e.getWrapped()); + throw new ConfigurationException("config.10", new Object[] { e + .toString() }, e); + } + + } + @Test public void dummyTest() throws Exception { } - + @Test public void parseIdl() throws Exception { String idlB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_IDL); @@ -47,10 +78,27 @@ public abstract class eIDDataVerifierTest { if (idl == null) throw new Exception("IDL parsing FAILED"); + + } + + @Test + public void verifyIdl() throws Exception { + String idlB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_IDL); + if (MiscUtil.isEmpty(idlB64)) + throw new Exception("NO IDL found"); + + IIdentityLink idl = new IdentityLinkAssertionParser(new ByteArrayInputStream(Base64Utils.decode(idlB64, false))).parseIdentityLink(); + + if (idl == null) + throw new Exception("IDL parsing FAILED"); + + IOAAuthParameters dummyOA = new DummyOA(); + AuthConfiguration dummyAuthConfig = new DummyAuthConfig(); + QualifiedeIDVerifier.verifyIdentityLink(idl, dummyOA , dummyAuthConfig); } - //@Test + @Test public void parseAuthBlock() throws Exception { String authBlockB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_AUTHBLOCK); if (MiscUtil.isEmpty(authBlockB64)) @@ -61,7 +109,21 @@ public abstract class eIDDataVerifierTest { } - //@Test + + + @Test + public void verifyAuthBlock() throws Exception { + String authBlockB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_AUTHBLOCK); + if (MiscUtil.isEmpty(authBlockB64)) + throw new Exception("NO AuthBlock found"); + + IOAAuthParameters dummyOA = new DummyOA(); + AuthConfiguration dummyAuthConfig = new DummyAuthConfig(); + QualifiedeIDVerifier.verifyAuthBlock(authBlockB64, dummyOA , dummyAuthConfig); + + } + + @Test public void checkIDLAgainstAuthblock() throws Exception { String authBlockB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_AUTHBLOCK); String idlB64 = eIDData.get(SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_IDL); @@ -76,29 +138,12 @@ public abstract class eIDDataVerifierTest { IOAAuthParameters dummyOA = new DummyOA(); AuthConfiguration dummyAuthConfig = new DummyAuthConfig(); - - Logger.info("Loading Java security providers."); - System.setProperty("moa.spss.server.configuration", "F:\\Projekte\\configs\\moa-spss\\MOASPSSConfiguration.xml"); - - IAIK.addAsProvider(); - ECCelerate.addAsProvider(); - try { - LoggingContextManager.getInstance().setLoggingContext( - new LoggingContext("startup")); - Logger.debug("Starting MOA-SPSS initialization process ... "); - Configurator.getInstance().init(); - Logger.info("MOA-SPSS initialization complete "); - - } catch (MOAException e) { - Logger.error("MOA-SP initialization FAILED!", e.getWrapped()); - throw new ConfigurationException("config.10", new Object[] { e - .toString() }, e); - } - - QualifiedeIDVerifier.verifyIdentityLink(idl, dummyOA , dummyAuthConfig); + IVerifiyXMLSignatureResponse authBlockVerificationResult = QualifiedeIDVerifier.verifyAuthBlock(authBlockB64, dummyOA , dummyAuthConfig); QualifiedeIDVerifier.checkConsistencyOfeIDData(getSl20ReqId(), idl, authBlockExtractor, authBlockVerificationResult); + + } protected abstract String getSl20ReqId(); |