diff options
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/at/gv/util/MiscUtil.java | 16 | ||||
-rw-r--r-- | src/main/java/at/gv/util/data/ElectronicIdentity.java | 5 | ||||
-rw-r--r-- | src/test/java/at/gv/util/demo/Clienttests.java | 250 |
4 files changed, 209 insertions, 64 deletions
@@ -5,7 +5,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>at.gv.util</groupId> <artifactId>egovutils</artifactId> - <version>2.0.3</version> + <version>2.0.4</version> <name>zuseutil</name> <url>http://maven.apache.org</url> <properties> diff --git a/src/main/java/at/gv/util/MiscUtil.java b/src/main/java/at/gv/util/MiscUtil.java index 7ad055e..c0095f8 100644 --- a/src/main/java/at/gv/util/MiscUtil.java +++ b/src/main/java/at/gv/util/MiscUtil.java @@ -276,11 +276,27 @@ public class MiscUtil { } } + /** + * Parse XML date in date object in UTC timezone + * + * @param xmlDate String based date with pattern "yyyy-MM-dd" + * @return + * @throws EgovUtilException + */ public static Date parseXMLDate(String xmlDate) throws EgovUtilException { + return parseXMLDate(xmlDate, TimeZone.getTimeZone("UTC")); + + } + + public static Date parseXMLDate(String xmlDate, TimeZone zone) throws EgovUtilException { if (xmlDate == null) { return null; } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + if (zone != null) + sdf.setTimeZone(zone); + try { return sdf.parse(xmlDate); } catch (ParseException e) { diff --git a/src/main/java/at/gv/util/data/ElectronicIdentity.java b/src/main/java/at/gv/util/data/ElectronicIdentity.java index 4483e86..ea5bd25 100644 --- a/src/main/java/at/gv/util/data/ElectronicIdentity.java +++ b/src/main/java/at/gv/util/data/ElectronicIdentity.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; +import java.util.TimeZone; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -378,7 +379,7 @@ public final class ElectronicIdentity implements Serializable, Empty, RoleContai this.baseId = ppt.getIdentification().get(0).getValue().getValue(); this.firstName = ppt.getName().getGivenName().get(0); this.lastName = ppt.getName().getFamilyName().get(0).getValue(); - this.dateOfBirth = MiscUtil.parseXMLDate(ppt.getDateOfBirth()); + this.dateOfBirth = MiscUtil.parseXMLDate(ppt.getDateOfBirth(), TimeZone.getTimeZone("UTC")); } } } @@ -451,7 +452,7 @@ public final class ElectronicIdentity implements Serializable, Empty, RoleContai this.setBaseId(baseId); this.setZbpk(BpkUtil.calcZBPK(baseId)); this.setVzbpk(BpkUtil.calcVZBPK(baseId)); - this.setDateOfBirth(MiscUtil.parseXMLDate(ppt.getDateOfBirth())); + this.setDateOfBirth(MiscUtil.parseXMLDate(ppt.getDateOfBirth(), TimeZone.getTimeZone("UTC"))); this.setFirstName(ppt.getName().getGivenName().get(0)); this.setLastName(ppt.getName().getFamilyName().get(0).getValue()); } else if ("bkuURL".equals(attr.getAttributeName())) { diff --git a/src/test/java/at/gv/util/demo/Clienttests.java b/src/test/java/at/gv/util/demo/Clienttests.java index e984263..7cf0fe0 100644 --- a/src/test/java/at/gv/util/demo/Clienttests.java +++ b/src/test/java/at/gv/util/demo/Clienttests.java @@ -5,33 +5,43 @@ import iaik.security.ecc.interfaces.ECDSAPublicKey; import iaik.security.ecc.math.ecgroup.AffineCoordinate; import iaik.security.ecc.math.ecgroup.ECPoint; import iaik.security.ecc.provider.ECCProvider; +import iaik.x509.X509Certificate; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.math.BigInteger; import java.security.InvalidKeyException; import java.security.PublicKey; +import java.security.cert.CertificateException; import java.security.interfaces.DSAParams; import java.security.interfaces.DSAPublicKey; import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAPublicKey; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Properties; +import java.util.TimeZone; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import javax.xml.transform.TransformerException; import org.apache.cxf.common.util.Base64Utility; +import org.apache.cxf.helpers.IOUtils; import org.w3c.dom.Element; import at.gv.util.BpkUtil; import at.gv.util.DOMUtils; +import at.gv.util.MiscUtil; import at.gv.util.client.szr.SZRClient; import at.gv.util.client.ur_V5.URClient; import at.gv.util.client.ur_V5.URClient.URSearchResult; @@ -49,12 +59,15 @@ import at.gv.util.xsd.szr.ecdsa.ECDSAKeyValueType; import at.gv.util.xsd.szr.ecdsa.ECPointType; import at.gv.util.xsd.szr.ecdsa.NamedCurveType; import at.gv.util.xsd.szr.ecdsa.PrimeFieldElemType; +import at.gv.util.xsd.szr.persondata.DeliveryAddressType; import at.gv.util.xsd.szr.persondata.IdentificationType; import at.gv.util.xsd.szr.persondata.PersonNameType; import at.gv.util.xsd.szr.persondata.PhysicalPersonType; +import at.gv.util.xsd.szr.persondata.PostalAddressType; import at.gv.util.xsd.szr.xmldsig.DSAKeyValueType; import at.gv.util.xsd.szr.xmldsig.KeyValueType; import at.gv.util.xsd.szr.xmldsig.RSAKeyValueType; +import at.gv.util.xsd.ur_V5.pd.NichtNatuerlichePersonTyp; public class Clienttests { @@ -108,7 +121,7 @@ public class Clienttests { try { SZRClient szrClient = new SZRClient(egovUtilConfiguration); - URClient urClient = new URClient(egovUtilConfiguration, UR_TYPES, ERSB_KEYS, false, false); + URClient urClient = new URClient(egovUtilConfiguration, UR_TYPES, ERSB_KEYS, false, true); PersonInfoType personInfo = new PersonInfoType(); @@ -118,28 +131,126 @@ public class Clienttests { person.setName(personName ); IdentificationType id = new IdentificationType(); + PostalAddressType address = new PostalAddressType(); + // id.setType(SSPIN_PREFIX + "ZP"); // id.setValue("U/wThc0XOTZp9Tvsxrh8DhGTXsU="); // person.setIdentification(id); - personName.setFamilyName("Karning"); - personName.setGivenName("Bernhard"); - person.setDateOfBirth("1976-01-15"); + personName.setFamilyName("Lenz"); + personName.setGivenName("Thomas"); + person.setDateOfBirth("1982-09-06"); + + personName.setFamilyName("ALLMBlasznig ELGATest"); + personName.setGivenName("Reinfried"); + person.setDateOfBirth("1943-06-26"); + personName.setFamilyName("Buxbaum"); + personName.setGivenName("Georg"); + person.setDateOfBirth("1964-10-09"); + + personName.setFamilyName("Eder"); + personName.setGivenName("Michaela"); + person.setDateOfBirth("1971-04-25"); +// id.setType(SSPIN_PREFIX + "ZP"); +// id.setValue("T2wnifoq7CJDyhhWod7+YiZilLA="); +// person.setIdentification(id); +// personName.setFamilyName("Buxbaum"); +// personName.setGivenName("Doris"); +// person.setDateOfBirth("1976-05-26"); - String baseID = szrClient.getStammzahl(personInfo ); +// personName.setFamilyName("Lackner"); +// personName.setGivenName("Christiane"); +// person.setDateOfBirth("1965-04-22"); + +// personName.setFamilyName("Karning"); +// personName.setGivenName("Bernhard"); +// person.setDateOfBirth("1976-01-15"); + +// personName.setFamilyName("Müller"); +// personName.setGivenName("Harald"); +// person.setDateOfBirth("1964-10-30"); +// personInfo.setRegularDomicile(address ); +// address.setPostalCode("1130"); +// personName.setFamilyName("Rudinger"); +// personName.setGivenName("Franz"); +// person.setDateOfBirth("1973-04-18"); + +// personName.setFamilyName("Pointner"); +// personName.setGivenName("Johann"); +//// person.setDateOfBirth("1954-07-07"); +// personInfo.setRegularDomicile(address); +// DeliveryAddressType delivAddr = new DeliveryAddressType(); +//// address.setMunicipality("Linz"); +// //address.setLocality("Wels"); +// address.setPostalCode("4030"); + + + //String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZP", "BBA-STA"); +// String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZU", "BBA-STA"); +// +// + + //InputStream is = Clienttests.class.getResourceAsStream("/clearing_geburtstage_mit_UTC_versatz_20180214.csv"); + InputStream is = Clienttests.class.getResourceAsStream("/clearing_geburtstage_mit_UTC_versatz_20180305.csv"); + String data = IOUtils.toString(is); + for (String line : data.split("\\n")) { + try { + String[] el = line.split(","); + + personName.setFamilyName(el[4]); + personName.setGivenName(el[3]); + + String date = el[5].substring(1, el[5].length()-1); + Date test = MiscUtil.parseDate(date, "yyyy-MM-dd", TimeZone.getTimeZone("UTC")); + Date tomorrow = new Date(test.getTime() + (1000 * 60 * 60 * 24)); + person.setDateOfBirth(MiscUtil.formatDate(tomorrow, "yyyy-MM-dd")); + + + String baseID = szrClient.getStammzahl(personInfo ); + System.out.println("OK!!! " + person.getName().getGivenName() + " " + person.getName().getFamilyName()); + + + } catch ( Exception e) { + e.printStackTrace(); + } + + + } + + + + + personName.setFamilyName("Hembach"); + personName.setGivenName("Alfred"); + person.setDateOfBirth("1975-03-02"); + + personName.setFamilyName("Atzlinger"); + personName.setGivenName("Manfred"); + person.setDateOfBirth("1964-01-29"); + + personName.setFamilyName("Doppler"); + personName.setGivenName("Dominik"); + person.setDateOfBirth("1998-04-14"); + + String baseID = szrClient.getStammzahl(personInfo ); +// BPK zpBpk = BpkUtil.createBPK(baseID, "ZP"); +// +// personInfo.getPerson().setDateOfBirth(null); - String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BBA-STA"); +// String test = szrClient.getBPK(personInfo, "BF", "BBA-STA"); + +// String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BBA-STA"); // GetIdentityLink idlReq = createGetIdentityLink(); -// -// String baseIDResp = szrClient.getStammzahl(personInfo); -// +//// +////// String baseIDResp = szrClient.getStammzahl(personInfo); +////// // IdentityLinkType idlResp = szrClient.getIdentityLink( // idlReq.getPersonInfo(), // idlReq.getKeyValue(), @@ -147,71 +258,89 @@ public class Clienttests { // Element idl = (Element)idlResp.getAssertion(); // System.out.println(DOMUtils.serializeNode(idl)); +// FileOutputStream writeToFile = new FileOutputStream("D:/local_work/zertifikate/ELGA_mocca_testcards/Allwsoker_Elgatest.idl"); +// writeToFile.write(DOMUtils.serializeNode(idl).getBytes()); +// writeToFile.close(); - List<URSearchResult> urResult = urClient.searchByBpk(encryptedbPK); - - System.out.println("Finish"); - - + +// List<NichtNatuerlichePersonTyp> urResult = urClient.searchByRegisterNumber("9110008265019", "ERJ", 10); - } catch (EgovUtilException e) { - // TODO Auto-generated catch block - e.printStackTrace(); +// urResult = urClient.searchByName("Bundesministerium*", null, 10); - } catch (SZRException e) { - // TODO Auto-generated catch block - e.printStackTrace(); +// List<URSearchResult> urResult = urClient.searchByBpk(encryptedbPK); +// List<URSearchResult> urResult = urClient.searchByRegisterNumberFullInfo("237384w", "FBN", 10); - } catch (URClientException e) { - // TODO Auto-generated catch block + System.out.println("Finish"); + + } catch (Exception e) { e.printStackTrace(); } } - private static GetIdentityLink createGetIdentityLink(){ + private static GetIdentityLink createGetIdentityLink() throws CertificateException, IOException{ // set parameter GetIdentityLink getIdentityLink = new GetIdentityLink(); + + SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); + PersonInfoType personInfo = new PersonInfoType(); + PhysicalPersonType physicalPerson = new PhysicalPersonType(); + PostalAddressType address = new PostalAddressType(); // generate PersonData PersonNameType personName = new PersonNameType(); - personName.setFamilyName("Janez Vzorec"); - personName.setGivenName("Janez Vzorec"); - - PhysicalPersonType physicalPerson = new PhysicalPersonType(); - SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); - - String birthday = "1998-12-06"; +// personName.setFamilyName("Janez Vzorec"); +// personName.setGivenName("Janez Vzorec"); + +// personName.setFamilyName("ALLWSoker ELGATest"); +// personName.setGivenName("Zilli Winnimar"); + +// personName.setFamilyName("Pointner"); +// personName.setGivenName("Johann"); +// address.setMunicipality("Linz"); +// address.setPostalCode("4030"); +// String birthday = "1954-07-07"; +// String birthday = "1928-04-10"; + + personName.setFamilyName("Kern"); + personName.setGivenName("Thomas"); + String birthday = null; + address.setMunicipality("Obdach"); + address.setPostalCode("8742"); + + + + + //String birthday = "1998-12-06"; if (birthday != null) physicalPerson.setDateOfBirth(birthday); physicalPerson.setName(personName); - - PersonInfoType personInfo = new PersonInfoType(); + if (address != null) + personInfo.setRegularDomicile(address); personInfo.setPerson(physicalPerson); - - + // add Traveldocument - TravelDocumentType trvlDoc = new TravelDocumentType(); - - // parse STORK-eID to his components - //ERnB allows only eIDs with a maximum length of 54 signs - trvlDoc.setDocumentNumber("33333333"); - trvlDoc.setIssuingCountry("SI"); - trvlDoc.setDocumentType(DOCUMENT_TYPE); - - //set default values from SZR because certificate for mandator natural person is not - //available in case of authentication with electronic mandates. - trvlDoc.setIssueDate(ERnB_ISSUEDATE); - trvlDoc.setIssuingAuthority(ERnB_ISSUINGAUTHORITY); - - JAXBElement<TravelDocumentType> jaxbtrvlDoc = personInfo.getTravelDocument(); - - if (jaxbtrvlDoc == null) - jaxbtrvlDoc = new JAXBElement<TravelDocumentType>(new QName("urn:SZRServices", "TravelDocument"), TravelDocumentType.class, trvlDoc); - else - jaxbtrvlDoc.setValue(trvlDoc); +// TravelDocumentType trvlDoc = new TravelDocumentType(); +// +// // parse STORK-eID to his components +// //ERnB allows only eIDs with a maximum length of 54 signs +// trvlDoc.setDocumentNumber("33333333"); +// trvlDoc.setIssuingCountry("SI"); +// trvlDoc.setDocumentType(DOCUMENT_TYPE); +// +// //set default values from SZR because certificate for mandator natural person is not +// //available in case of authentication with electronic mandates. +// trvlDoc.setIssueDate(ERnB_ISSUEDATE); +// trvlDoc.setIssuingAuthority(ERnB_ISSUINGAUTHORITY); +// +// JAXBElement<TravelDocumentType> jaxbtrvlDoc = personInfo.getTravelDocument(); +// +// if (jaxbtrvlDoc == null) +// jaxbtrvlDoc = new JAXBElement<TravelDocumentType>(new QName("urn:SZRServices", "TravelDocument"), TravelDocumentType.class, trvlDoc); +// else +// jaxbtrvlDoc.setValue(trvlDoc); //personInfo.setTravelDocument(jaxbtrvlDoc); @@ -226,15 +355,14 @@ public class Clienttests { keyvalueList = new ArrayList<KeyValueType>(); - try { - pb = new iaik.security.rsa.RSAPublicKey(DEFAULT_PUBL_KEY); - List<KeyValueType> keys = getKeyValueTypes(pb); - keyvalueList.addAll(keys); - - } catch (InvalidKeyException e) { - e.printStackTrace(); + InputStream importCertStream = new FileInputStream("F:/local_work/zertifikate/mocca_testcards/BRZ_testcards/test_identities/Achim XXXZastrow/secure.crt"); + X509Certificate importCert = new X509Certificate(importCertStream ); + pb = importCert.getPublicKey(); + + //pb = new iaik.security.rsa.RSAPublicKey(DEFAULT_PUBL_KEY); + List<KeyValueType> keys = getKeyValueTypes(pb); + keyvalueList.addAll(keys); - } // set Insert ERnP flag getIdentityLink.setInsertERnP(false); |