diff options
Diffstat (limited to 'src/test/java/at/gv/util/demo/Clienttests.java')
-rw-r--r-- | src/test/java/at/gv/util/demo/Clienttests.java | 247 |
1 files changed, 167 insertions, 80 deletions
diff --git a/src/test/java/at/gv/util/demo/Clienttests.java b/src/test/java/at/gv/util/demo/Clienttests.java index 7cf0fe0..c439d2d 100644 --- a/src/test/java/at/gv/util/demo/Clienttests.java +++ b/src/test/java/at/gv/util/demo/Clienttests.java @@ -30,6 +30,7 @@ import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.TimeZone; +import java.util.regex.Pattern; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -42,6 +43,7 @@ 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.mis.usp_v2.USPClient; import at.gv.util.client.szr.SZRClient; import at.gv.util.client.ur_V5.URClient; import at.gv.util.client.ur_V5.URClient.URSearchResult; @@ -50,6 +52,7 @@ import at.gv.util.config.EgovUtilPropertiesConfiguration; import at.gv.util.data.BPK; import at.gv.util.ex.EgovUtilException; import at.gv.util.wsdl.szr.SZRException; +import at.gv.util.xsd.szr.FremdBPKType; import at.gv.util.xsd.szr.GetIdentityLink; import at.gv.util.xsd.szr.IdentityLinkType; import at.gv.util.xsd.szr.PersonInfoType; @@ -93,10 +96,14 @@ public class Clienttests { public static final String DOCUMENT_TYPE = "ELEKTR_DOKUMENT"; public static final String ERnB_ISSUEDATE = "2014-01-01"; public static final String ERnB_ISSUINGAUTHORITY = "SZR-Gateway"; + + public final static Pattern URN_PATTERN = Pattern.compile( + "^urn:[a-z0-9][a-z0-9-]{0,31}:([a-z0-9()+,\\-.:=@;$_!*']|%[0-9a-f]{2})+$", + Pattern.CASE_INSENSITIVE); @SuppressWarnings("unused") public static void main(String[] args) throws IOException { - + String propertiesFileLocation = System.getProperty("mis.configuration"); if (propertiesFileLocation == null) { @@ -138,21 +145,29 @@ public class Clienttests { // id.setValue("U/wThc0XOTZp9Tvsxrh8DhGTXsU="); // person.setIdentification(id); - 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"); +// personName.setFamilyName("Lenz"); +// personName.setGivenName("Thomas"); +// person.setDateOfBirth("1982-09-06"); + +// personName.setFamilyName("XXXTüzekçi"); +// personName.setGivenName("XXXŐzgür"); +// person.setDateOfBirth("1973-06-04"); + +// personName.setFamilyName("Tauber"); +// personName.setGivenName("Arne"); +// person.setDateOfBirth("1979-08-21"); +// +// 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); @@ -179,6 +194,10 @@ public class Clienttests { // personName.setGivenName("Franz"); // person.setDateOfBirth("1973-04-18"); +// personName.setFamilyName("Drabina"); +// personName.setGivenName("Sonja"); +// person.setDateOfBirth("1969-09-23"); + // personName.setFamilyName("Pointner"); // personName.setGivenName("Johann"); //// person.setDateOfBirth("1954-07-07"); @@ -189,72 +208,126 @@ public class Clienttests { // address.setPostalCode("4030"); - //String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZP", "BBA-STA"); +// String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZP-MH", "BKA"); // 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(); - } - - - } +// 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"); + ///Datenschutzbehörde +// personName.setFamilyName("Wollrab"); +// personName.setGivenName("Michael"); +// person.setDateOfBirth("1981-04-27"); - personName.setFamilyName("Hembach"); - personName.setGivenName("Alfred"); - person.setDateOfBirth("1975-03-02"); +// personName.setFamilyName("Sollinger"); +// personName.setGivenName("Moritz"); +// //person.setDateOfBirth("1997-08-09"); +// IdentificationType eid = new IdentificationType(); +// eid.setType("urn:publicid:gv.at:cdid+ZP"); +// eid.setValue("gd4u4WNDjV3xBYMcuBmj2vwhH88="); +// person.setIdentification(eid ); +// +// personName.setFamilyName("Ruzizka"); +// personName.setGivenName("Nina Christina"); +// person.setDateOfBirth("1982-08-27"); - personName.setFamilyName("Atzlinger"); - personName.setGivenName("Manfred"); - person.setDateOfBirth("1964-01-29"); +// personName.setFamilyName("El Fohail"); +// personName.setGivenName("Samraa"); +// person.setDateOfBirth("1975-01-13"); - personName.setFamilyName("Doppler"); - personName.setGivenName("Dominik"); - person.setDateOfBirth("1998-04-14"); +// personName.setFamilyName("Allwgeppert Elgatest"); +// personName.setGivenName("Amèlîè"); +// person.setDateOfBirth("1943-07-03"); + + personName.setFamilyName("Mustermann"); + personName.setGivenName("Max"); + person.setDateOfBirth("1940-01-01"); String baseID = szrClient.getStammzahl(personInfo ); -// + BPK zpBpk = BpkUtil.createBPK(baseID, "ZP"); +// BPK zpBpk = BpkUtil.createBPK(baseID, "ZP-MH"); +// System.out.print(zpBpk); + // // personInfo.getPerson().setDateOfBirth(null); // String test = szrClient.getBPK(personInfo, "BF", "BBA-STA"); // String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BBA-STA"); + FremdBPKType encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BMF"); +// String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "ZU", "ZUSETNVZ"); + + + + /* + *USP V2 Client tests + * + */ + USPClient uspClient = new USPClient(egovUtilConfiguration, true); + +// uspClient.getMandates( +// encryptedbPK.getBereichsKennung(), +// encryptedbPK.getFremdBPK(), +// Arrays.asList("MPK_Postvollmacht")); + +// uspClient.getMandates( +// "urn:publicid:gv.at:ecdid+BMF+WT-UR", +// "CfAUGvuKyy8q9ZGLKI1WloY3ihkQ3vJis40grN9M6Eud+YU9EDXWkqdsVnznIpHaCc1cCUMA5+YorDhIZyvabxvty8Rwiq3PBHVMVc4/+jjkx2qkqOodM3gOQHG1TsPbSRl7tysCukGpdgK7NJFdh0mTlsYUwLatSsi+Qv0lTYU=", +// Arrays.asList("MPK_Postvollmacht")); // GetIdentityLink idlReq = createGetIdentityLink(); //// -////// String baseIDResp = szrClient.getStammzahl(personInfo); +/// String baseIDResp = szrClient.getStammzahl(personInfo); ////// // IdentityLinkType idlResp = szrClient.getIdentityLink( // idlReq.getPersonInfo(), // idlReq.getKeyValue(), -// false); +// true); // Element idl = (Element)idlResp.getAssertion(); // System.out.println(DOMUtils.serializeNode(idl)); @@ -264,6 +337,7 @@ public class Clienttests { // List<NichtNatuerlichePersonTyp> urResult = urClient.searchByRegisterNumber("9110008265019", "ERJ", 10); + List<NichtNatuerlichePersonTyp> urResult = urClient.searchByRegisterNumber("9110008265019", "ERK", 10); // urResult = urClient.searchByName("Bundesministerium*", null, 10); @@ -277,7 +351,7 @@ public class Clienttests { } } - private static GetIdentityLink createGetIdentityLink() throws CertificateException, IOException{ + private static GetIdentityLink createGetIdentityLink() throws CertificateException, IOException, InvalidKeyException{ // set parameter GetIdentityLink getIdentityLink = new GetIdentityLink(); @@ -302,47 +376,53 @@ public class Clienttests { // 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"); +// personName.setFamilyName("Lenz"); +// personName.setGivenName("Thomas"); +// String birthday = null; +// birthday = "1982-09-06"; +// address.setMunicipality("Obdach"); +// address.setPostalCode("8742"); - + + personName.setFamilyName("Farbenfroh"); + personName.setGivenName("Jonatan"); + String birthday = null; + birthday = "1978-08-25"; - //String birthday = "1998-12-06"; + if (birthday != null) physicalPerson.setDateOfBirth(birthday); physicalPerson.setName(personName); - if (address != null) - personInfo.setRegularDomicile(address); +// if (address != null) +// personInfo.setRegularDomicile(address); + personInfo.setPerson(physicalPerson); // add Traveldocument -// TravelDocumentType trvlDoc = new TravelDocumentType(); + 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); + trvlDoc.setDocumentNumber("12345678abcde"); + 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); + JAXBElement<TravelDocumentType> jaxbtrvlDoc = personInfo.getTravelDocument(); - //personInfo.setTravelDocument(jaxbtrvlDoc); + if (jaxbtrvlDoc == null) + jaxbtrvlDoc = new JAXBElement<TravelDocumentType>(new QName("urn:SZRServices", "TravelDocument"), TravelDocumentType.class, trvlDoc); + else + jaxbtrvlDoc.setValue(trvlDoc); + + personInfo.setTravelDocument(jaxbtrvlDoc); // Personendaten setzen getIdentityLink.setPersonInfo(personInfo); @@ -355,17 +435,24 @@ public class Clienttests { keyvalueList = new ArrayList<KeyValueType>(); - 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(); +// 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); + pb = new iaik.security.rsa.RSAPublicKey(DEFAULT_PUBL_KEY); List<KeyValueType> keys = getKeyValueTypes(pb); keyvalueList.addAll(keys); +// KeyValueType testvalue = new KeyValueType(); +// RSAKeyValueType rsaKeyValue = new RSAKeyValueType(); +// rsaKeyValue.setExponent("Forever"); +// rsaKeyValue.setModulus("Kandi");; +// testvalue.setRSAKeyValue(rsaKeyValue ); +// keyvalueList.add(testvalue); + // set Insert ERnP flag - getIdentityLink.setInsertERnP(false); + getIdentityLink.setInsertERnP(true); // Constants.DATA_LOGGER.debug("Person wird im SZR und ERnP gesucht bzw. gegebenenfalls im ERnP eingetragen: " // + natPerson.getFamilyName() + " " + natPerson.getGivenName() + " " + natPerson.getBirthday() |