summaryrefslogtreecommitdiff
path: root/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java')
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java101
1 files changed, 101 insertions, 0 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java
new file mode 100644
index 00000000..db97f4ca
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/IdentityLinkTest.java
@@ -0,0 +1,101 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.PublicKey;
+import java.security.interfaces.RSAPublicKey;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.springframework.util.Base64Utils;
+
+import at.gv.egiz.eaaf.core.exceptions.EaafParserException;
+import at.gv.egiz.eaaf.core.impl.idp.auth.data.IdentityLink;
+import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class IdentityLinkTest {
+
+ private IdentityLink idl = null;
+
+ /**
+ * jUnit test set-up.
+ * @throws EaafParserException In case of an error
+ * @throws UnsupportedEncodingException In case of an unsupported encoding
+ */
+ @Before
+ public void testInit() throws EaafParserException, UnsupportedEncodingException {
+ idl = (IdentityLink) new SimpleIdentityLinkAssertionParser(
+ new ByteArrayInputStream(Base64Utils.decode(AuthenticationDataBuilderTest.DUMMY_IDL_2.getBytes("UTF-8")))).parseIdentityLink();
+
+ }
+
+ @Test
+ public void checkElement() {
+ Assert.assertNotNull("DateOfBirth", idl.getDateOfBirth());
+ Assert.assertNotNull("FamilyName", idl.getFamilyName());
+ Assert.assertNotNull("GivenNamae", idl.getGivenName());
+ Assert.assertNotNull("baseIdType", idl.getIdentificationType());
+ Assert.assertNotNull("baseid", idl.getIdentificationValue());
+ Assert.assertNotNull("IssuerInstant", idl.getIssueInstant());
+ Assert.assertNotNull("name", idl.getName());
+ Assert.assertNotNull("prPerson", idl.getPrPerson());
+ Assert.assertNotNull("Assertion element", idl.getSamlAssertion());
+ Assert.assertNotNull("Assertion serialized", idl.getSerializedSamlAssertion());
+ Assert.assertNotNull("Transform ref", idl.getDsigReferenceTransforms());
+ Assert.assertEquals("Transform Size not match", 1, idl.getDsigReferenceTransforms().length);
+
+ }
+
+ @Test
+ public void checkPubKeys() {
+ PublicKey[] publicKey = new RSAPublicKey[2];
+ publicKey[0] = generatePubKey();
+ publicKey[1] = generatePubKey();
+
+ idl.setPublicKey(publicKey );
+
+ Assert.assertNotNull("PubKey", idl.getPublicKey());
+ Assert.assertEquals("PubKeys not match", publicKey.length, idl.getPublicKey().length);
+
+ }
+
+ private PublicKey generatePubKey() {
+ return new RSAPublicKey() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public BigInteger getModulus() {
+ return new BigInteger(RandomStringUtils.randomNumeric(10));
+ }
+
+ @Override
+ public String getFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getAlgorithm() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigInteger getPublicExponent() {
+ return new BigInteger(RandomStringUtils.randomNumeric(2));
+ }
+ };
+ }
+}