summaryrefslogtreecommitdiff
path: root/eaaf_modules/eaaf_module_auth_sl20/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_modules/eaaf_module_auth_sl20/src/test')
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/AbstractJsonSecurityUtilsTest.java1
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JoseUtilsTest.java83
2 files changed, 1 insertions, 83 deletions
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/AbstractJsonSecurityUtilsTest.java b/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/AbstractJsonSecurityUtilsTest.java
index ae4284d5..18ac843f 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/AbstractJsonSecurityUtilsTest.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/AbstractJsonSecurityUtilsTest.java
@@ -36,6 +36,7 @@ import at.gv.egiz.eaaf.core.impl.credential.EaafKeyStoreUtils;
import at.gv.egiz.eaaf.core.impl.credential.KeyStoreConfiguration;
import at.gv.egiz.eaaf.core.impl.credential.KeyStoreConfiguration.KeyStoreType;
import at.gv.egiz.eaaf.core.impl.data.Pair;
+import at.gv.egiz.eaaf.core.impl.utils.JoseUtils;
import at.gv.egiz.eaaf.core.test.dummy.DummyAuthConfigMap;
import at.gv.egiz.eaaf.modules.auth.sl20.data.VerificationResult;
import iaik.security.ec.provider.ECCelerate;
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JoseUtilsTest.java b/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JoseUtilsTest.java
deleted file mode 100644
index b5a7639e..00000000
--- a/eaaf_modules/eaaf_module_auth_sl20/src/test/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JoseUtilsTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package at.gv.egiz.eaaf.modules.auth.sl20.utils;
-
-import java.io.IOException;
-import java.security.NoSuchProviderException;
-import java.security.Security;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.jose4j.jwa.AlgorithmConstraints;
-import org.jose4j.jwa.AlgorithmConstraints.ConstraintType;
-import org.jose4j.jws.AlgorithmIdentifiers;
-import org.jose4j.lang.JoseException;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.BlockJUnit4ClassRunner;
-
-import at.gv.egiz.eaaf.modules.auth.sl20.utils.JoseUtils.JwsResult;
-import iaik.security.ec.provider.ECCelerate;
-import iaik.security.provider.IAIK;
-
-@RunWith(BlockJUnit4ClassRunner.class)
-public class JoseUtilsTest {
-
- private static final List<String> BINDING_AUTH_ALGORITHM_WHITELIST_SIGNING = Collections.unmodifiableList(
- Arrays.asList(
- AlgorithmIdentifiers.ECDSA_USING_P256_CURVE_AND_SHA256,
- AlgorithmIdentifiers.ECDSA_USING_P521_CURVE_AND_SHA512,
- AlgorithmIdentifiers.RSA_PSS_USING_SHA256,
- AlgorithmIdentifiers.RSA_PSS_USING_SHA512));
-
- /**
- *jUnit test class initializer.
- */
- @BeforeClass
- public static final void classInitializer() {
- IAIK.addAsProvider();
- ECCelerate.addAsProvider();
-
- }
-
- /**
- * jUnit test class cleaner.
- */
- @AfterClass
- public static final void classFinisher() {
- Security.removeProvider(IAIK.getInstance().getName());
- Security.removeProvider(ECCelerate.getInstance().getName());
-
- }
-
- @Test
- public void testBindingAuthBlock() throws JoseException, IOException, CertificateException, NoSuchProviderException {
-
- final String serializedContent = IOUtils.toString(JoseUtils.class.getResourceAsStream(
- "/data/bindingAuth1.jws"), "UTF-8");
-
- final iaik.x509.X509Certificate trustedCert = new iaik.x509.X509Certificate(JoseUtils.class
- .getResourceAsStream("/data/bindingAuth1.crt"));
-
- final List<X509Certificate> trustedCerts = Arrays.asList(trustedCert);
- final AlgorithmConstraints constraints = new AlgorithmConstraints(ConstraintType.PERMIT,
- BINDING_AUTH_ALGORITHM_WHITELIST_SIGNING
- .toArray(new String[BINDING_AUTH_ALGORITHM_WHITELIST_SIGNING.size()]));
-
- final JwsResult result = JoseUtils.validateSignature(serializedContent, trustedCerts, constraints);
-
- Assert.assertNotNull("JWS verify result", result);
- Assert.assertTrue("JWS not valid", result.isValid());
- Assert.assertNotNull("JWS payload", result.getPayLoad());
- Assert.assertNotNull("JWS Headers", result.getFullJoseHeader());
- Assert.assertNotNull("JWS Signercerts", result.getX5cCerts());
- Assert.assertEquals("Signercerts size", 1, result.getX5cCerts().size());
- Assert.assertArrayEquals("Signercerts", trustedCert.getEncoded(), result.getX5cCerts().get(0).getEncoded());
-
- }
-}