diff options
author | rudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-01-21 18:28:42 +0000 |
---|---|---|
committer | rudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-01-21 18:28:42 +0000 |
commit | 1d8f51ba16c681ed82f55609c918acc2553d21da (patch) | |
tree | 2da17f7ca60828615f575ba8ea8fad64e844b70e | |
parent | 048c9c94da9d4a1c9a5397634c4cb4a8604c3397 (diff) | |
download | moa-id-spss-1d8f51ba16c681ed82f55609c918acc2553d21da.tar.gz moa-id-spss-1d8f51ba16c681ed82f55609c918acc2553d21da.tar.bz2 moa-id-spss-1d8f51ba16c681ed82f55609c918acc2553d21da.zip |
added ECDSA Key handling
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@241 d688527b-c9ab-4aba-bd8d-4036d912da1d
-rw-r--r-- | id.server/src/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParser.java | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParser.java b/id.server/src/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParser.java index 49baf1bf5..dd44419da 100644 --- a/id.server/src/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParser.java +++ b/id.server/src/at/gv/egovernment/moa/id/auth/parser/IdentityLinkAssertionParser.java @@ -19,6 +19,7 @@ import at.gv.egovernment.moa.util.Base64Utils; import at.gv.egovernment.moa.util.Constants; import at.gv.egovernment.moa.util.DOMUtils; import at.gv.egovernment.moa.util.XPathUtils; +import at.gv.egovernment.moa.id.util.ECDSAKeyValueConverter; /** * Parses an identity link <code><saml:Assertion></code> @@ -118,6 +119,20 @@ public class IdentityLinkAssertionParser { + "AttributeValue/" + DSIG + "RSAKeyValue"; + + /** Xpath expression to the ECKeyValue element */ + private static final String ECDSA_KEY_VALUE_XPATH = + ROOT + + SAML + + "AttributeStatement/" + + SAML + + "Attribute/" + + SAML + + "AttributeValue/" + + ECDSA + + "ECDSAKeyValue"; + + /** Xpath expression to the RSA Modulus element */ private static final String RSA_KEY_MODULUS_XPATH = DSIG + "Modulus"; /** Xpath expression to the RSA Exponent element */ @@ -228,14 +243,15 @@ public class IdentityLinkAssertionParser { * @return RSAPublicKey[] * @throws IOException can occur when decoding the base64 values of the modulus and exponent */ - public PublicKey[] getPublicKeys() throws IOException{ + public PublicKey[] getPublicKeys() throws IOException, ECDSAConverterException{ List pubKeys = new ArrayList(); //Try to get RSA-Keys NodeIterator rsaIter = - XPathUtils.selectNodeIterator(assertionElem, RSA_KEY_VALUE_XPATH); + XPathUtils.selectNodeIterator(assertionElem, Constants.nSMap, RSA_KEY_VALUE_XPATH); Element rsaElem; + while ((rsaElem = (Element) rsaIter.nextNode()) != null) { String modulus = XPathUtils.getElementValue(rsaElem, RSA_KEY_MODULUS_XPATH, ""); @@ -246,10 +262,26 @@ public class IdentityLinkAssertionParser { new iaik.security.rsa.RSAPublicKey( new BigInteger(1, Base64Utils.decode(modulus, true)), new BigInteger(1, Base64Utils.decode(exponent, true))); - pubKeys.add(resPub);} + pubKeys.add(resPub); + } + + //Try to get ECDSA-Keys + NodeIterator ecdsaIter = + XPathUtils.selectNodeIterator(assertionElem, Constants.nSMap, ECDSA_KEY_VALUE_XPATH); + Element ecdsaElem; + PublicKey ecPubKey = null; + while ((ecdsaElem = (Element) ecdsaIter.nextNode()) != null) { + try { + ecPubKey = ECDSAKeyValueConverter.element2ECDSAPublicKey(ecdsaElem); + pubKeys.add(ecPubKey); + } + catch(Exception e) { + //TODO test + throw new ECDSAConverterException("parser.03", new Object[] { e.toString() }, e); + } + } PublicKey[] result = new PublicKey[pubKeys.size()]; - pubKeys.toArray(result); return result; |