From 33dfef091acd2d28e68658c8e0bcb4e67027d1e1 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Thu, 3 Nov 2016 16:17:03 +0100 Subject: Workaround for finding EC OID if ECCelerate not loaded first --- .../egiz/idlink/CompressedIdentityLinkFactory.java | 16 +- .../at/gv/egiz/idlink/ans1/CitizenPublicKey.java | 100 ------- .../java/at/gv/egiz/idlink/ans1/IdentityLink.java | 323 --------------------- .../java/at/gv/egiz/idlink/ans1/PersonData.java | 99 ------- .../at/gv/egiz/idlink/ans1/PhysicalPersonData.java | 151 ---------- .../at/gv/egiz/idlink/asn1/CitizenPublicKey.java | 100 +++++++ .../java/at/gv/egiz/idlink/asn1/IdentityLink.java | 323 +++++++++++++++++++++ .../java/at/gv/egiz/idlink/asn1/PersonData.java | 99 +++++++ .../at/gv/egiz/idlink/asn1/PhysicalPersonData.java | 151 ++++++++++ .../java/at/gv/egiz/xmldsig/KeyValueFactory.java | 62 +++- .../at/gv/egiz/idlink/CompressIdentityLink.java | 2 +- 11 files changed, 738 insertions(+), 688 deletions(-) delete mode 100644 utils/src/main/java/at/gv/egiz/idlink/ans1/CitizenPublicKey.java delete mode 100644 utils/src/main/java/at/gv/egiz/idlink/ans1/IdentityLink.java delete mode 100644 utils/src/main/java/at/gv/egiz/idlink/ans1/PersonData.java delete mode 100644 utils/src/main/java/at/gv/egiz/idlink/ans1/PhysicalPersonData.java create mode 100644 utils/src/main/java/at/gv/egiz/idlink/asn1/CitizenPublicKey.java create mode 100644 utils/src/main/java/at/gv/egiz/idlink/asn1/IdentityLink.java create mode 100644 utils/src/main/java/at/gv/egiz/idlink/asn1/PersonData.java create mode 100644 utils/src/main/java/at/gv/egiz/idlink/asn1/PhysicalPersonData.java (limited to 'utils/src') diff --git a/utils/src/main/java/at/gv/egiz/idlink/CompressedIdentityLinkFactory.java b/utils/src/main/java/at/gv/egiz/idlink/CompressedIdentityLinkFactory.java index 510f303e..11908540 100644 --- a/utils/src/main/java/at/gv/egiz/idlink/CompressedIdentityLinkFactory.java +++ b/utils/src/main/java/at/gv/egiz/idlink/CompressedIdentityLinkFactory.java @@ -51,14 +51,14 @@ import org.w3c.dom.NodeList; import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType; import at.gv.e_government.reference.namespace.persondata._20020228_.AbstractPersonType; import at.gv.e_government.reference.namespace.persondata._20020228_.IdentificationType; -import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType; -import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPersonType; import at.gv.e_government.reference.namespace.persondata._20020228_.IdentificationType.Value; +import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType; import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType.FamilyName; -import at.gv.egiz.idlink.ans1.CitizenPublicKey; -import at.gv.egiz.idlink.ans1.IdentityLink; -import at.gv.egiz.idlink.ans1.PersonData; -import at.gv.egiz.idlink.ans1.PhysicalPersonData; +import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPersonType; +import at.gv.egiz.idlink.asn1.CitizenPublicKey; +import at.gv.egiz.idlink.asn1.IdentityLink; +import at.gv.egiz.idlink.asn1.PersonData; +import at.gv.egiz.idlink.asn1.PhysicalPersonData; import at.gv.egiz.marshal.MarshallerFactory; import at.gv.egiz.xmldsig.KeyTypeNotSupportedException; import at.gv.egiz.xmldsig.KeyValueFactory; @@ -201,7 +201,7 @@ public class CompressedIdentityLinkFactory { * of the certificates list */ public JAXBElement createCompressedIdentityLink( - at.gv.egiz.idlink.ans1.IdentityLink idLink, + at.gv.egiz.idlink.asn1.IdentityLink idLink, List certificates, String domainId) { at.gv.e_government.reference.namespace.persondata._20020228_.ObjectFactory prFactory = @@ -254,7 +254,7 @@ public class CompressedIdentityLinkFactory { X509Certificate certificate = certificates.get(__citizenPublicKey.getOnToken()); PublicKey publicKey = certificate.getPublicKey(); - + JAXBElement keyValue; try { keyValue = keyValueFactory.createKeyValue(publicKey); diff --git a/utils/src/main/java/at/gv/egiz/idlink/ans1/CitizenPublicKey.java b/utils/src/main/java/at/gv/egiz/idlink/ans1/CitizenPublicKey.java deleted file mode 100644 index 5e342b8d..00000000 --- a/utils/src/main/java/at/gv/egiz/idlink/ans1/CitizenPublicKey.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2011 by Graz University of Technology, Austria - * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint - * initiative of the Federal Chancellery Austria and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - - -package at.gv.egiz.idlink.ans1; - -import java.math.BigInteger; - -import iaik.asn1.*; - -/** - * This class implements the ASN.1 representation of the - * CitizenPublicKey of a compressed identity link. - * - *
CitizenPublicKey ::= CHOICE { 
-    onToken [0] INTEGER, 
-    referenceURL [1] UTF8String, 
-    x509Data [2] SubjectPublicKeyInfo 
-}  
-
- * - * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at - */ -public class CitizenPublicKey implements ASN1Type { - - /** - * onToken - */ - private int onToken; // INTEGER - - /** - * Creates a new CitizenPublicKey with the given - * onToken value. - * - * @param onToken - */ - public CitizenPublicKey(int onToken) { - this.onToken = onToken; - } - - /** - * Creates a new CitizenPublicKey from the given ASN.1 representation. - * - * @param obj - * @throws CodingException - */ - public CitizenPublicKey(ASN1Object obj) throws CodingException { - decode(obj); - } - - @Override - public void decode(ASN1Object obj) throws CodingException { - try { - BigInteger Value = (BigInteger)(obj.getValue()); - onToken = Value.intValue(); - } catch (Exception ex) { - throw new CodingException(ex.toString()); - } - } - - @Override - public ASN1Object toASN1Object() { - INTEGER ot = new INTEGER(onToken); - return ot; - } - - /** - * Returns the DER encoding of this CitizenPublicKey. - * - * @return the DER encoding of this CitizenPublicKey - */ - public byte[] getEncoded() { - return DerCoder.encode(toASN1Object()); - } - - public int getOnToken() { - return onToken; - } - -} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/idlink/ans1/IdentityLink.java b/utils/src/main/java/at/gv/egiz/idlink/ans1/IdentityLink.java deleted file mode 100644 index 6a250b9a..00000000 --- a/utils/src/main/java/at/gv/egiz/idlink/ans1/IdentityLink.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright 2011 by Graz University of Technology, Austria - * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint - * initiative of the Federal Chancellery Austria and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - - -package at.gv.egiz.idlink.ans1; - -import iaik.asn1.ASN1Object; -import iaik.asn1.ASN1Type; -import iaik.asn1.BIT_STRING; -import iaik.asn1.CON_SPEC; -import iaik.asn1.CodingException; -import iaik.asn1.DerCoder; -import iaik.asn1.INTEGER; -import iaik.asn1.SEQUENCE; -import iaik.asn1.UTF8String; - -/** - * This class impelments an ASN.1 representation of the compressed IdentiyLink. - *
-PersonenBindung ::= SEQUENCE { 
-    version INTEGER, 
-    issuerTemplate UTF8String, 
-    assertionID UTF8String, 
-    issueInstant UTF8String, 
-    personData PersonData, 
-    citizenPublicKey SEQUENCE SIZE (1..MAX) OF CitizenPublicKey, 
-    signatureValue BIT STRING, 
-    referenceDigest [0] BIT STRING OPTIONAL, 
-    referenceManifestDigest [1] BIT STRING OPTIONAL, 
-    manifestReferenceDigest [2] BIT STRING OPTIONAL 
-} 
-
- * - * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at - */ -public class IdentityLink implements ASN1Type { - - private int version = 1; // INTEGER - private String issuerTemplate; // UTF8String - private String assertionID; // UTF8String - private String issueInstant; // UTF8String - private PersonData personData; // PersonData - private CitizenPublicKey[] citizenPublicKeys; // SEQUENCE SIZE (1..MAX) OF - private byte[] signatureValue; // BIT STRING - private byte[] referenceDigest; // BIT STRING OPTIONAL - private byte[] referenceManifestDigest; // BIT STRING OPTIONAL - private byte[] manifestReferenceDigest; // BIT STRING OPTIONAL - - /** - * Creates a new IdentityLink with the given - * issuerTemplate, assertionID, - * issueInstant, personData, - * citizenPublicKeys and signatureValue. - * - * @param issuerTemplate - * @param assertionID - * @param issueInstant - * @param personData - * @param citizenPublicKeys - * @param signatureValue - */ - public IdentityLink(String issuerTemplate, String assertionID, - String issueInstant, PersonData personData, - CitizenPublicKey[] citizenPublicKeys, byte[] signatureValue) { - this.issuerTemplate = issuerTemplate; - this.assertionID = assertionID; - this.issueInstant = issueInstant; - this.personData = personData; - this.citizenPublicKeys = citizenPublicKeys; - this.signatureValue = signatureValue; - } - - /** - * Create a new IdentityLink from an ASN1Object. - * - * @param identiyLink - * @throws CodingException - */ - public IdentityLink(ASN1Object identiyLink) throws CodingException { - decode(identiyLink); - } - - @Override - public void decode(ASN1Object obj) throws CodingException { - issuerTemplate = (String) ((ASN1Object) obj.getComponentAt(1)).getValue(); - assertionID = (String) ((ASN1Object) obj.getComponentAt(2)).getValue(); - issueInstant = (String) ((ASN1Object) obj.getComponentAt(3)).getValue(); - - if (((CON_SPEC) obj.getComponentAt(4)).getAsnType().getTag() == 0) - personData = new PersonData((ASN1Object) obj.getComponentAt(4).getValue()); - else { - throw new CodingException("CorporateBodyData currently not supported."); - } - - SEQUENCE publicKeySequence = (SEQUENCE) obj.getComponentAt(5); - int anz = publicKeySequence.countComponents(); - citizenPublicKeys = new CitizenPublicKey[anz]; - for (int i = 0; i < citizenPublicKeys.length; i++) { - CON_SPEC tmp = (CON_SPEC) publicKeySequence.getComponentAt(i); - if (tmp.getAsnType().getTag() == 0) { - citizenPublicKeys[i] = new CitizenPublicKey((ASN1Object) tmp.getValue()); - } else { - throw new CodingException( - "Currently only PublicKeys on token are supported."); - } - } - - signatureValue = (byte[]) ((ASN1Object) obj.getComponentAt(6)).getValue(); - - for (int i = 7; i < obj.countComponents(); i++) { - CON_SPEC tmp = (CON_SPEC) obj.getComponentAt(i); - switch (tmp.getAsnType().getTag()) { - case 0: - referenceDigest = (byte[]) ((BIT_STRING) tmp.getValue()).getValue(); - break; - case 1: - referenceManifestDigest = (byte[]) ((BIT_STRING) tmp.getValue()) - .getValue(); - break; - case 2: - manifestReferenceDigest = (byte[]) ((BIT_STRING) tmp.getValue()) - .getValue(); - break; - } - - } - - } - - @Override - public ASN1Object toASN1Object() { - SEQUENCE pb = new SEQUENCE(); - pb.addComponent(new INTEGER(version)); - pb.addComponent(new UTF8String(issuerTemplate)); - pb.addComponent(new UTF8String(assertionID)); - pb.addComponent(new UTF8String(issueInstant)); - - pb.addComponent(new CON_SPEC(0, personData.toASN1Object())); - SEQUENCE seq = new SEQUENCE(); - for (int i = 0; i < citizenPublicKeys.length; i++) { - seq.addComponent(new CON_SPEC(0, citizenPublicKeys[i].toASN1Object())); - } - pb.addComponent(seq); - pb.addComponent(new BIT_STRING(signatureValue)); - if (referenceDigest != null) - pb.addComponent(new CON_SPEC(0, new BIT_STRING(referenceDigest))); - if (referenceManifestDigest != null) - pb.addComponent(new CON_SPEC(1, new BIT_STRING(referenceManifestDigest))); - if (manifestReferenceDigest != null) - pb.addComponent(new CON_SPEC(2, new BIT_STRING(manifestReferenceDigest))); - return pb; - } - - /** - * Returns the DER encoding of this IdentityLink. - * - * @return the DER encoding of this IdentityLink - */ - public byte[] toByteArray() { - return DerCoder.encode(toASN1Object()); - } - - /** - * @return the version - */ - public int getVersion() { - return version; - } - - /** - * @param version the version to set - */ - public void setVersion(int version) { - this.version = version; - } - - /** - * @return the issuerTemplate - */ - public String getIssuerTemplate() { - return issuerTemplate; - } - - /** - * @param issuerTemplate the issuerTemplate to set - */ - public void setIssuerTemplate(String issuerTemplate) { - this.issuerTemplate = issuerTemplate; - } - - /** - * @return the assertionID - */ - public String getAssertionID() { - return assertionID; - } - - /** - * @param assertionID the assertionID to set - */ - public void setAssertionID(String assertionID) { - this.assertionID = assertionID; - } - - /** - * @return the issueInstant - */ - public String getIssueInstant() { - return issueInstant; - } - - /** - * @param issueInstant the issueInstant to set - */ - public void setIssueInstant(String issueInstant) { - this.issueInstant = issueInstant; - } - - /** - * @return the personData - */ - public PersonData getPersonData() { - return personData; - } - - /** - * @param personData the personData to set - */ - public void setPersonData(PersonData personData) { - this.personData = personData; - } - - /** - * @return the citizenPublicKeys - */ - public CitizenPublicKey[] getCitizenPublicKeys() { - return citizenPublicKeys; - } - - /** - * @param citizenPublicKeys the citizenPublicKeys to set - */ - public void setCitizenPublicKeys(CitizenPublicKey[] citizenPublicKeys) { - this.citizenPublicKeys = citizenPublicKeys; - } - - /** - * @return the signatureValue - */ - public byte[] getSignatureValue() { - return signatureValue; - } - - /** - * @param signatureValue the signatureValue to set - */ - public void setSignatureValue(byte[] signatureValue) { - this.signatureValue = signatureValue; - } - - /** - * @return the referenceDigest - */ - public byte[] getReferenceDigest() { - return referenceDigest; - } - - /** - * @param referenceDigest the referenceDigest to set - */ - public void setReferenceDigest(byte[] referenceDigest) { - this.referenceDigest = referenceDigest; - } - - /** - * @return the referenceManifestDigest - */ - public byte[] getReferenceManifestDigest() { - return referenceManifestDigest; - } - - /** - * @param referenceManifestDigest the referenceManifestDigest to set - */ - public void setReferenceManifestDigest(byte[] referenceManifestDigest) { - this.referenceManifestDigest = referenceManifestDigest; - } - - /** - * @return the manifestReferenceDigest - */ - public byte[] getManifestReferenceDigest() { - return manifestReferenceDigest; - } - - /** - * @param manifestReferenceDigest the manifestReferenceDigest to set - */ - public void setManifestReferenceDigest(byte[] manifestReferenceDigest) { - this.manifestReferenceDigest = manifestReferenceDigest; - } - -} diff --git a/utils/src/main/java/at/gv/egiz/idlink/ans1/PersonData.java b/utils/src/main/java/at/gv/egiz/idlink/ans1/PersonData.java deleted file mode 100644 index 6204e370..00000000 --- a/utils/src/main/java/at/gv/egiz/idlink/ans1/PersonData.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2011 by Graz University of Technology, Austria - * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint - * initiative of the Federal Chancellery Austria and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - - -package at.gv.egiz.idlink.ans1; - -import iaik.asn1.*; - -/** - * This class represents the ASN.1 version of the PersonData - * of a compressed identity link. - * - *
-PersonData ::= CHOICE { 
-    physcialPerson [0] PhysicalPersonData, 
-    corporateBody [1] CorporateBodyData 
-} 
- * - * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at - * - */ -public class PersonData implements ASN1Type { - - /** - * physicalPerson - */ - private PhysicalPersonData physicalPerson; // PhysicalPersonData - - /** - * Creates a new PersonData with the given - * physicalPersonData. - * - * @param physicalPersonData - */ - public PersonData(PhysicalPersonData physicalPersonData) { - physicalPerson = physicalPersonData; - } - - /** - * Creates a new PersonData from its ASN.1 representation. - * - * @param obj - * @throws CodingException - */ - public PersonData(ASN1Object obj) throws CodingException { - decode(obj); - } - - @Override - public void decode(ASN1Object obj) throws CodingException { - try { - physicalPerson = new PhysicalPersonData(obj); - } catch (Exception ex) { - throw new CodingException(ex.toString()); - } - } - - @Override - public ASN1Object toASN1Object() { - return physicalPerson.toASN1Object(); - } - - /** - * Returns the DER encoded representation of this PersonData. - * - * @return the DER encoded representation of this PersonData - */ - public byte[] getEncoded() { - return DerCoder.encode(toASN1Object()); - } - - /** - * @return the physicalPerson - */ - public PhysicalPersonData getPhysicalPerson() { - return physicalPerson; - } - -} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/idlink/ans1/PhysicalPersonData.java b/utils/src/main/java/at/gv/egiz/idlink/ans1/PhysicalPersonData.java deleted file mode 100644 index 995a40f6..00000000 --- a/utils/src/main/java/at/gv/egiz/idlink/ans1/PhysicalPersonData.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2011 by Graz University of Technology, Austria - * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint - * initiative of the Federal Chancellery Austria and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - - -package at.gv.egiz.idlink.ans1; - -import iaik.asn1.*; - -/** - * This class represents the ASN.1 version of the PhysicalPersonData - * of an compressed identity link. - * - *
PhysicalPersonData ::= SEQUENCE { 
-    baseId UTF8String, 
-    givenName UTF8String, 
-    familyName UTF8String, 
-    dateOfBirth UTF8String
-}
- * - * @author mivkovic@egiz.gv.at, mcentner@eigz.gv.at - */ -public class PhysicalPersonData implements ASN1Type { - - /** - * baseId - */ - private String baseId; // UTF8String - - /** - * givenName - */ - private String givenName; // UTF8String - - /** - * familyName - */ - private String familyName; // UTF8String - - /** - * dataOfBirth - */ - private String dateOfBirth; // UTF8String - - /** - * Creates a new PhysicalPersonData with the - * given baseId, givenName, familyName - * and dataOfBirth. - * - * @param baseId - * @param givenName - * @param familyName - * @param dateOfBirth - */ - public PhysicalPersonData(String baseId, String givenName, String familyName, String dateOfBirth) { - this.baseId = baseId; - this.givenName = givenName; - this.familyName = familyName; - this.dateOfBirth = dateOfBirth; - } - - /** - * Creates a new PhysicalPersonData from its ASN.1 representation. - * - * @param obj - * - * @throws CodingException - */ - public PhysicalPersonData(ASN1Object obj) throws CodingException { - decode(obj); - } - - @Override - public void decode(ASN1Object obj) throws CodingException { - try { - baseId = (String) ((ASN1Object) obj.getComponentAt(0)).getValue(); - givenName = (String) ((ASN1Object) obj.getComponentAt(1)).getValue(); - familyName = (String) ((ASN1Object) obj.getComponentAt(2)).getValue(); - dateOfBirth = (String) ((ASN1Object) obj.getComponentAt(3)).getValue(); - } catch (Exception ex) { - throw new CodingException(ex.toString()); - } - } - - @Override - public ASN1Object toASN1Object() { - SEQUENCE ppd = new SEQUENCE(); - ppd.addComponent(new UTF8String(baseId)); - ppd.addComponent(new UTF8String(givenName)); - ppd.addComponent(new UTF8String(familyName)); - ppd.addComponent(new UTF8String(dateOfBirth)); - return ppd; - } - - /** - * Returns the DER encoding of this PhysicalPersonData. - * - * @return the DER encoding of this PhysicalPersonData - */ - public byte[] toByteArray() { - return DerCoder.encode(toASN1Object()); - } - - /** - * @return the baseId - */ - public String getBaseId() { - return baseId; - } - - /** - * @return the givenName - */ - public String getGivenName() { - return givenName; - } - - /** - * @return the familyName - */ - public String getFamilyName() { - return familyName; - } - - /** - * @return the dateOfBirth - */ - public String getDateOfBirth() { - return dateOfBirth; - } - -} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/idlink/asn1/CitizenPublicKey.java b/utils/src/main/java/at/gv/egiz/idlink/asn1/CitizenPublicKey.java new file mode 100644 index 00000000..f89511ff --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/idlink/asn1/CitizenPublicKey.java @@ -0,0 +1,100 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package at.gv.egiz.idlink.asn1; + +import java.math.BigInteger; + +import iaik.asn1.*; + +/** + * This class implements the ASN.1 representation of the + * CitizenPublicKey of a compressed identity link. + * + *
CitizenPublicKey ::= CHOICE { 
+    onToken [0] INTEGER, 
+    referenceURL [1] UTF8String, 
+    x509Data [2] SubjectPublicKeyInfo 
+}  
+
+ * + * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at + */ +public class CitizenPublicKey implements ASN1Type { + + /** + * onToken + */ + private int onToken; // INTEGER + + /** + * Creates a new CitizenPublicKey with the given + * onToken value. + * + * @param onToken + */ + public CitizenPublicKey(int onToken) { + this.onToken = onToken; + } + + /** + * Creates a new CitizenPublicKey from the given ASN.1 representation. + * + * @param obj + * @throws CodingException + */ + public CitizenPublicKey(ASN1Object obj) throws CodingException { + decode(obj); + } + + @Override + public void decode(ASN1Object obj) throws CodingException { + try { + BigInteger Value = (BigInteger)(obj.getValue()); + onToken = Value.intValue(); + } catch (Exception ex) { + throw new CodingException(ex.toString()); + } + } + + @Override + public ASN1Object toASN1Object() { + INTEGER ot = new INTEGER(onToken); + return ot; + } + + /** + * Returns the DER encoding of this CitizenPublicKey. + * + * @return the DER encoding of this CitizenPublicKey + */ + public byte[] getEncoded() { + return DerCoder.encode(toASN1Object()); + } + + public int getOnToken() { + return onToken; + } + +} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/idlink/asn1/IdentityLink.java b/utils/src/main/java/at/gv/egiz/idlink/asn1/IdentityLink.java new file mode 100644 index 00000000..c2663971 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/idlink/asn1/IdentityLink.java @@ -0,0 +1,323 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package at.gv.egiz.idlink.asn1; + +import iaik.asn1.ASN1Object; +import iaik.asn1.ASN1Type; +import iaik.asn1.BIT_STRING; +import iaik.asn1.CON_SPEC; +import iaik.asn1.CodingException; +import iaik.asn1.DerCoder; +import iaik.asn1.INTEGER; +import iaik.asn1.SEQUENCE; +import iaik.asn1.UTF8String; + +/** + * This class impelments an ASN.1 representation of the compressed IdentiyLink. + *
+PersonenBindung ::= SEQUENCE { 
+    version INTEGER, 
+    issuerTemplate UTF8String, 
+    assertionID UTF8String, 
+    issueInstant UTF8String, 
+    personData PersonData, 
+    citizenPublicKey SEQUENCE SIZE (1..MAX) OF CitizenPublicKey, 
+    signatureValue BIT STRING, 
+    referenceDigest [0] BIT STRING OPTIONAL, 
+    referenceManifestDigest [1] BIT STRING OPTIONAL, 
+    manifestReferenceDigest [2] BIT STRING OPTIONAL 
+} 
+
+ * + * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at + */ +public class IdentityLink implements ASN1Type { + + private int version = 1; // INTEGER + private String issuerTemplate; // UTF8String + private String assertionID; // UTF8String + private String issueInstant; // UTF8String + private PersonData personData; // PersonData + private CitizenPublicKey[] citizenPublicKeys; // SEQUENCE SIZE (1..MAX) OF + private byte[] signatureValue; // BIT STRING + private byte[] referenceDigest; // BIT STRING OPTIONAL + private byte[] referenceManifestDigest; // BIT STRING OPTIONAL + private byte[] manifestReferenceDigest; // BIT STRING OPTIONAL + + /** + * Creates a new IdentityLink with the given + * issuerTemplate, assertionID, + * issueInstant, personData, + * citizenPublicKeys and signatureValue. + * + * @param issuerTemplate + * @param assertionID + * @param issueInstant + * @param personData + * @param citizenPublicKeys + * @param signatureValue + */ + public IdentityLink(String issuerTemplate, String assertionID, + String issueInstant, PersonData personData, + CitizenPublicKey[] citizenPublicKeys, byte[] signatureValue) { + this.issuerTemplate = issuerTemplate; + this.assertionID = assertionID; + this.issueInstant = issueInstant; + this.personData = personData; + this.citizenPublicKeys = citizenPublicKeys; + this.signatureValue = signatureValue; + } + + /** + * Create a new IdentityLink from an ASN1Object. + * + * @param identiyLink + * @throws CodingException + */ + public IdentityLink(ASN1Object identiyLink) throws CodingException { + decode(identiyLink); + } + + @Override + public void decode(ASN1Object obj) throws CodingException { + issuerTemplate = (String) ((ASN1Object) obj.getComponentAt(1)).getValue(); + assertionID = (String) ((ASN1Object) obj.getComponentAt(2)).getValue(); + issueInstant = (String) ((ASN1Object) obj.getComponentAt(3)).getValue(); + + if (((CON_SPEC) obj.getComponentAt(4)).getAsnType().getTag() == 0) + personData = new PersonData((ASN1Object) obj.getComponentAt(4).getValue()); + else { + throw new CodingException("CorporateBodyData currently not supported."); + } + + SEQUENCE publicKeySequence = (SEQUENCE) obj.getComponentAt(5); + int anz = publicKeySequence.countComponents(); + citizenPublicKeys = new CitizenPublicKey[anz]; + for (int i = 0; i < citizenPublicKeys.length; i++) { + CON_SPEC tmp = (CON_SPEC) publicKeySequence.getComponentAt(i); + if (tmp.getAsnType().getTag() == 0) { + citizenPublicKeys[i] = new CitizenPublicKey((ASN1Object) tmp.getValue()); + } else { + throw new CodingException( + "Currently only PublicKeys on token are supported."); + } + } + + signatureValue = (byte[]) ((ASN1Object) obj.getComponentAt(6)).getValue(); + + for (int i = 7; i < obj.countComponents(); i++) { + CON_SPEC tmp = (CON_SPEC) obj.getComponentAt(i); + switch (tmp.getAsnType().getTag()) { + case 0: + referenceDigest = (byte[]) ((BIT_STRING) tmp.getValue()).getValue(); + break; + case 1: + referenceManifestDigest = (byte[]) ((BIT_STRING) tmp.getValue()) + .getValue(); + break; + case 2: + manifestReferenceDigest = (byte[]) ((BIT_STRING) tmp.getValue()) + .getValue(); + break; + } + + } + + } + + @Override + public ASN1Object toASN1Object() { + SEQUENCE pb = new SEQUENCE(); + pb.addComponent(new INTEGER(version)); + pb.addComponent(new UTF8String(issuerTemplate)); + pb.addComponent(new UTF8String(assertionID)); + pb.addComponent(new UTF8String(issueInstant)); + + pb.addComponent(new CON_SPEC(0, personData.toASN1Object())); + SEQUENCE seq = new SEQUENCE(); + for (int i = 0; i < citizenPublicKeys.length; i++) { + seq.addComponent(new CON_SPEC(0, citizenPublicKeys[i].toASN1Object())); + } + pb.addComponent(seq); + pb.addComponent(new BIT_STRING(signatureValue)); + if (referenceDigest != null) + pb.addComponent(new CON_SPEC(0, new BIT_STRING(referenceDigest))); + if (referenceManifestDigest != null) + pb.addComponent(new CON_SPEC(1, new BIT_STRING(referenceManifestDigest))); + if (manifestReferenceDigest != null) + pb.addComponent(new CON_SPEC(2, new BIT_STRING(manifestReferenceDigest))); + return pb; + } + + /** + * Returns the DER encoding of this IdentityLink. + * + * @return the DER encoding of this IdentityLink + */ + public byte[] toByteArray() { + return DerCoder.encode(toASN1Object()); + } + + /** + * @return the version + */ + public int getVersion() { + return version; + } + + /** + * @param version the version to set + */ + public void setVersion(int version) { + this.version = version; + } + + /** + * @return the issuerTemplate + */ + public String getIssuerTemplate() { + return issuerTemplate; + } + + /** + * @param issuerTemplate the issuerTemplate to set + */ + public void setIssuerTemplate(String issuerTemplate) { + this.issuerTemplate = issuerTemplate; + } + + /** + * @return the assertionID + */ + public String getAssertionID() { + return assertionID; + } + + /** + * @param assertionID the assertionID to set + */ + public void setAssertionID(String assertionID) { + this.assertionID = assertionID; + } + + /** + * @return the issueInstant + */ + public String getIssueInstant() { + return issueInstant; + } + + /** + * @param issueInstant the issueInstant to set + */ + public void setIssueInstant(String issueInstant) { + this.issueInstant = issueInstant; + } + + /** + * @return the personData + */ + public PersonData getPersonData() { + return personData; + } + + /** + * @param personData the personData to set + */ + public void setPersonData(PersonData personData) { + this.personData = personData; + } + + /** + * @return the citizenPublicKeys + */ + public CitizenPublicKey[] getCitizenPublicKeys() { + return citizenPublicKeys; + } + + /** + * @param citizenPublicKeys the citizenPublicKeys to set + */ + public void setCitizenPublicKeys(CitizenPublicKey[] citizenPublicKeys) { + this.citizenPublicKeys = citizenPublicKeys; + } + + /** + * @return the signatureValue + */ + public byte[] getSignatureValue() { + return signatureValue; + } + + /** + * @param signatureValue the signatureValue to set + */ + public void setSignatureValue(byte[] signatureValue) { + this.signatureValue = signatureValue; + } + + /** + * @return the referenceDigest + */ + public byte[] getReferenceDigest() { + return referenceDigest; + } + + /** + * @param referenceDigest the referenceDigest to set + */ + public void setReferenceDigest(byte[] referenceDigest) { + this.referenceDigest = referenceDigest; + } + + /** + * @return the referenceManifestDigest + */ + public byte[] getReferenceManifestDigest() { + return referenceManifestDigest; + } + + /** + * @param referenceManifestDigest the referenceManifestDigest to set + */ + public void setReferenceManifestDigest(byte[] referenceManifestDigest) { + this.referenceManifestDigest = referenceManifestDigest; + } + + /** + * @return the manifestReferenceDigest + */ + public byte[] getManifestReferenceDigest() { + return manifestReferenceDigest; + } + + /** + * @param manifestReferenceDigest the manifestReferenceDigest to set + */ + public void setManifestReferenceDigest(byte[] manifestReferenceDigest) { + this.manifestReferenceDigest = manifestReferenceDigest; + } + +} diff --git a/utils/src/main/java/at/gv/egiz/idlink/asn1/PersonData.java b/utils/src/main/java/at/gv/egiz/idlink/asn1/PersonData.java new file mode 100644 index 00000000..786486f1 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/idlink/asn1/PersonData.java @@ -0,0 +1,99 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package at.gv.egiz.idlink.asn1; + +import iaik.asn1.*; + +/** + * This class represents the ASN.1 version of the PersonData + * of a compressed identity link. + * + *
+PersonData ::= CHOICE { 
+    physcialPerson [0] PhysicalPersonData, 
+    corporateBody [1] CorporateBodyData 
+} 
+ * + * @author mivkovic@egiz.gv.at, mcentner@egiz.gv.at + * + */ +public class PersonData implements ASN1Type { + + /** + * physicalPerson + */ + private PhysicalPersonData physicalPerson; // PhysicalPersonData + + /** + * Creates a new PersonData with the given + * physicalPersonData. + * + * @param physicalPersonData + */ + public PersonData(PhysicalPersonData physicalPersonData) { + physicalPerson = physicalPersonData; + } + + /** + * Creates a new PersonData from its ASN.1 representation. + * + * @param obj + * @throws CodingException + */ + public PersonData(ASN1Object obj) throws CodingException { + decode(obj); + } + + @Override + public void decode(ASN1Object obj) throws CodingException { + try { + physicalPerson = new PhysicalPersonData(obj); + } catch (Exception ex) { + throw new CodingException(ex.toString()); + } + } + + @Override + public ASN1Object toASN1Object() { + return physicalPerson.toASN1Object(); + } + + /** + * Returns the DER encoded representation of this PersonData. + * + * @return the DER encoded representation of this PersonData + */ + public byte[] getEncoded() { + return DerCoder.encode(toASN1Object()); + } + + /** + * @return the physicalPerson + */ + public PhysicalPersonData getPhysicalPerson() { + return physicalPerson; + } + +} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/idlink/asn1/PhysicalPersonData.java b/utils/src/main/java/at/gv/egiz/idlink/asn1/PhysicalPersonData.java new file mode 100644 index 00000000..be92ac30 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/idlink/asn1/PhysicalPersonData.java @@ -0,0 +1,151 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package at.gv.egiz.idlink.asn1; + +import iaik.asn1.*; + +/** + * This class represents the ASN.1 version of the PhysicalPersonData + * of an compressed identity link. + * + *
PhysicalPersonData ::= SEQUENCE { 
+    baseId UTF8String, 
+    givenName UTF8String, 
+    familyName UTF8String, 
+    dateOfBirth UTF8String
+}
+ * + * @author mivkovic@egiz.gv.at, mcentner@eigz.gv.at + */ +public class PhysicalPersonData implements ASN1Type { + + /** + * baseId + */ + private String baseId; // UTF8String + + /** + * givenName + */ + private String givenName; // UTF8String + + /** + * familyName + */ + private String familyName; // UTF8String + + /** + * dataOfBirth + */ + private String dateOfBirth; // UTF8String + + /** + * Creates a new PhysicalPersonData with the + * given baseId, givenName, familyName + * and dataOfBirth. + * + * @param baseId + * @param givenName + * @param familyName + * @param dateOfBirth + */ + public PhysicalPersonData(String baseId, String givenName, String familyName, String dateOfBirth) { + this.baseId = baseId; + this.givenName = givenName; + this.familyName = familyName; + this.dateOfBirth = dateOfBirth; + } + + /** + * Creates a new PhysicalPersonData from its ASN.1 representation. + * + * @param obj + * + * @throws CodingException + */ + public PhysicalPersonData(ASN1Object obj) throws CodingException { + decode(obj); + } + + @Override + public void decode(ASN1Object obj) throws CodingException { + try { + baseId = (String) ((ASN1Object) obj.getComponentAt(0)).getValue(); + givenName = (String) ((ASN1Object) obj.getComponentAt(1)).getValue(); + familyName = (String) ((ASN1Object) obj.getComponentAt(2)).getValue(); + dateOfBirth = (String) ((ASN1Object) obj.getComponentAt(3)).getValue(); + } catch (Exception ex) { + throw new CodingException(ex.toString()); + } + } + + @Override + public ASN1Object toASN1Object() { + SEQUENCE ppd = new SEQUENCE(); + ppd.addComponent(new UTF8String(baseId)); + ppd.addComponent(new UTF8String(givenName)); + ppd.addComponent(new UTF8String(familyName)); + ppd.addComponent(new UTF8String(dateOfBirth)); + return ppd; + } + + /** + * Returns the DER encoding of this PhysicalPersonData. + * + * @return the DER encoding of this PhysicalPersonData + */ + public byte[] toByteArray() { + return DerCoder.encode(toASN1Object()); + } + + /** + * @return the baseId + */ + public String getBaseId() { + return baseId; + } + + /** + * @return the givenName + */ + public String getGivenName() { + return givenName; + } + + /** + * @return the familyName + */ + public String getFamilyName() { + return familyName; + } + + /** + * @return the dateOfBirth + */ + public String getDateOfBirth() { + return dateOfBirth; + } + +} \ No newline at end of file diff --git a/utils/src/main/java/at/gv/egiz/xmldsig/KeyValueFactory.java b/utils/src/main/java/at/gv/egiz/xmldsig/KeyValueFactory.java index 6377bf9f..2388405f 100644 --- a/utils/src/main/java/at/gv/egiz/xmldsig/KeyValueFactory.java +++ b/utils/src/main/java/at/gv/egiz/xmldsig/KeyValueFactory.java @@ -24,6 +24,7 @@ package at.gv.egiz.xmldsig; +import iaik.security.ec.common.ECStandardizedParameterFactory; import iaik.security.ec.errorhandling.InvalidCurveParameterSpecException; import java.math.BigInteger; @@ -39,6 +40,7 @@ import java.security.spec.ECFieldFp; import java.security.spec.ECParameterSpec; import java.security.spec.ECPoint; import java.security.spec.EllipticCurve; +import java.util.Enumeration; import javax.xml.bind.JAXBElement; @@ -48,6 +50,7 @@ import org.w3._2001._04.xmldsig_more_.BasePointParamsType; import org.w3._2001._04.xmldsig_more_.CharTwoFieldElemType; import org.w3._2001._04.xmldsig_more_.CurveParamsType; import org.w3._2001._04.xmldsig_more_.DomainParamsType; +import org.w3._2001._04.xmldsig_more_.DomainParamsType.NamedCurve; import org.w3._2001._04.xmldsig_more_.ECDSAKeyValueType; import org.w3._2001._04.xmldsig_more_.ECPointType; import org.w3._2001._04.xmldsig_more_.ExplicitParamsType; @@ -57,10 +60,8 @@ import org.w3._2001._04.xmldsig_more_.PnBFieldParamsType; import org.w3._2001._04.xmldsig_more_.PrimeFieldElemType; import org.w3._2001._04.xmldsig_more_.PrimeFieldParamsType; import org.w3._2001._04.xmldsig_more_.TnBFieldParamsType; -import org.w3._2001._04.xmldsig_more_.DomainParamsType.NamedCurve; public class KeyValueFactory { - private static byte[] bigInteger2byteArray(BigInteger bigPositiveInt) { if (bigPositiveInt == null) throw new NullPointerException("Argument 'bigPositiveInt' must not be null"); @@ -216,7 +217,53 @@ public class KeyValueFactory { } } - + + private boolean fieldsEqual(ECField f1, ECField f2) { + if (f1 instanceof ECFieldF2m) { + if (!(f2 instanceof ECFieldF2m)) { + return false; + } + ECFieldF2m f2m1 = (ECFieldF2m) f1; + ECFieldF2m f2m2 = (ECFieldF2m) f2; + return (f2m1.getM() == f2m2.getM() && f2m1.getReductionPolynomial().equals(f2m2.getReductionPolynomial())); + } else if (f1 instanceof ECFieldFp) { + if (!(f2 instanceof ECFieldFp)) { + return false; + } + ECFieldFp fp1 = (ECFieldFp) f1; + ECFieldFp fp2 = (ECFieldFp) f2; + return (fp1.getP().equals(fp2.getP())); + } + return false; + } + + private boolean curvesEqual(EllipticCurve c1, EllipticCurve c2) { + if (c1.getA().equals(c2.getA()) && c1.getB().equals(c2.getB())) + return fieldsEqual(c1.getField(), c2.getField()); + return false; + } + + private String findOID(ECParameterSpec params) { + EllipticCurve curve = params.getCurve(); + Enumeration oids = ECStandardizedParameterFactory.getPrimeCurveOIDs(); + while (oids.hasMoreElements()) { + String oid = oids.nextElement(); + iaik.security.ec.common.ECParameterSpec params2 = ECStandardizedParameterFactory.getParametersByOID(oid); + if (curvesEqual(curve, params2.getCurve())) { + return oid; + } + } + oids = ECStandardizedParameterFactory.getBinaryCurveOIDs(); + while (oids.hasMoreElements()) { + String oid = oids.nextElement(); + iaik.security.ec.common.ECParameterSpec params2 = ECStandardizedParameterFactory.getParametersByOID(oid); + if (curvesEqual(curve, params2.getCurve())) { + return oid; + } + } + return null; + } + public DomainParamsType createDomainParamsType(ECParameterSpec params) throws KeyTypeNotSupportedException { iaik.security.ec.common.ECParameterSpec params2; try { @@ -225,16 +272,19 @@ public class KeyValueFactory { throw new KeyTypeNotSupportedException(e); } DomainParamsType domainParamsType = ecFactory.createDomainParamsType(); - EllipticCurve curve = params.getCurve(); - String oid = params2.getOID(); - if (oid != null) { + if (oid == null) { + oid = findOID(params); + } + if (oid != null) { // NamedCurve NamedCurve namedCurve = ecFactory.createDomainParamsTypeNamedCurve(); namedCurve.setURN("urn:oid:" + oid); domainParamsType.setNamedCurve(namedCurve); } else { // Explicit parameters + EllipticCurve curve = params.getCurve(); + ExplicitParamsType explicitParamsType = ecFactory.createExplicitParamsType(); explicitParamsType.setFieldParams(createFieldParamsType(curve.getField())); diff --git a/utils/src/test/java/at/gv/egiz/idlink/CompressIdentityLink.java b/utils/src/test/java/at/gv/egiz/idlink/CompressIdentityLink.java index 562b4660..0d7624d9 100644 --- a/utils/src/test/java/at/gv/egiz/idlink/CompressIdentityLink.java +++ b/utils/src/test/java/at/gv/egiz/idlink/CompressIdentityLink.java @@ -33,7 +33,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType; -import at.gv.egiz.idlink.ans1.IdentityLink; +import at.gv.egiz.idlink.asn1.IdentityLink; public class CompressIdentityLink { -- cgit v1.2.3