diff options
Diffstat (limited to 'src/test/java/at/gv/util/demo')
-rw-r--r-- | src/test/java/at/gv/util/demo/Clienttests.java | 247 | ||||
-rw-r--r-- | src/test/java/at/gv/util/demo/ZuseSSLTest.java | 136 |
2 files changed, 303 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() diff --git a/src/test/java/at/gv/util/demo/ZuseSSLTest.java b/src/test/java/at/gv/util/demo/ZuseSSLTest.java new file mode 100644 index 0000000..359cb4e --- /dev/null +++ b/src/test/java/at/gv/util/demo/ZuseSSLTest.java @@ -0,0 +1,136 @@ +package at.gv.util.demo; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.Socket; +import java.security.Key; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.Base64; +import java.util.Collections; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.PrivateKeyDetails; +import org.apache.http.ssl.PrivateKeyStrategy; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.lf5.util.StreamUtils; + +import at.gv.util.xsd.szr.pvp.sec.Security; + +public class ZuseSSLTest { + + public static void main(String[] args) { + String keyStoreFile = "F:/Projekte/configs/mis/egiz.gv.at-816-2018-06-07.jks"; + char[] keyStorePassword = "OSgmSn!".toCharArray(); + char[] keyPassword = "nichts".toCharArray(); + + //String serviceURL = "https://pamgate2.portal.at/at.gv.usp.vdds-ws-q/Synchronisation?wsdl"; + String serviceURL = "https://pamgate2.portal.at/at.gv.usp.vdds-ws-q/Synchronisation"; + //serviceURL = "https://eid.egiz.gv.at/sslclientcertdemo/"; + + //String payLoadB64 = "PHNvYXA6RW52ZWxvcGUgeG1sbnM6c29hcD0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZlbG9wZS8iPg0KCTxzb2FwOkJvZHk+DQoJCTxuczM6TGlzdE1hbmRhdGVzUmVxdWVzdCB4bWxuczpuczM9Imh0dHA6Ly9lYWkuYnJ6Lmd2LmF0L3NlcnZpY2VzL3ZkZHMvc3luYy1tc2dzIiB4bWxucz0iaHR0cDovL2VhaS5icnouZ3YuYXQvc2VydmljZXMvdmRkcy90b2tlbiIgeG1sbnM6bnMyPSJodHRwOi8vZWFpLmJyei5ndi5hdC9zZXJ2aWNlcy92ZGRzL2NvbW1vbiIgeG1sbnM6bnM0PSJodHRwOi8vcmVmZXJlbmNlLmUtZ292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Wx1ZT4NCgkJCQkJCQk8bnM1OlR5cGU+dXJuOnB1YmxpY2lkOmd2LmF0OmNkaWQrWlA8L25zNTpUeXBlPg0KCQkJCQkJPC9uczM6UmVwcmVzZW50YXRpdmVJRD4NCgkJCQkJPC9uczM6U2VhcmNoQ3JpdGVyaWE+DQoJCQkJPC9uczM6RmlsdGVyPg0KCQkJPC9uczM6TWFuZGF0ZUF0dHJpYnV0ZXNTZWFyY2hGaWx0ZXI+DQoJCTwvbnMzOkxpc3RNYW5kYXRlc1JlcXVlc3Q+DQoJPC9zb2FwOkJvZHk+DQo8L3NvYXA6RW52ZWxvcGU+"; + try { + + SSLContextBuilder sslContext = new SSLContextBuilder(); + KeyStore keyStore = KeyStore.getInstance("JKS", "SUN"); + keyStore.load(new FileInputStream(new File(keyStoreFile)), keyStorePassword); + + + + PrivateKeyStrategy aliasStrategy = new PrivateKeyStrategy() { + @Override + public String chooseAlias(Map<String, PrivateKeyDetails> aliases, Socket socket) { + if (aliases != null && !aliases.isEmpty()) + return aliases.keySet().iterator().next(); + + return null; + } + + }; + + sslContext.loadKeyMaterial(keyStore, keyPassword, aliasStrategy); + sslContext.loadTrustMaterial(null, (certificate, authType) -> true); + + CloseableHttpClient client = HttpClients.custom() + .setSSLContext(sslContext.build()) + .setSSLHostnameVerifier(new NoopHostnameVerifier()) + .build(); + + HttpPost httpGet = new HttpPost(serviceURL); + //HttpGet httpGet = new HttpGet(serviceURL); + //httpGet.setHeader("Accept", "application/xml"); + + httpGet.setHeader("SOAPAction", "ListMandates"); + httpGet.setHeader("Accept", "*/*"); + + + //PVP 1.x header + httpGet.setHeader("X-VERSION", "1.8"); + httpGet.setHeader("X-AUTHENTICATE-UserID", "egiz@egiz.gv.at"); + httpGet.setHeader("X-AUTHENTICATE-GVGID", "gvGid"); + httpGet.setHeader("X-AUTHENTICATE-PARTICIPANTID", "AT:B:111"); + httpGet.setHeader("X-AUTHENTICATE-GVOUID", "EGIZ"); + httpGet.setHeader("X-AUTHENTICATE-OU", "EGIZ"); + httpGet.setHeader("X-AUTHENTICATE-GVFUNCTION", "gvFunctio"); + httpGet.setHeader("X-AUTHORIZE-ROLES", "VDDS-USP-VDDS-PARTNER"); + httpGet.setHeader("X-AUTHENTICATE-gvSecClass", "2"); + httpGet.setHeader("X-AUTHENTICATE-cn","E-Government Innovationszentrum"); + httpGet.setHeader("X-ACCOUNTING-CostCenterId", null); + httpGet.setHeader("X-ACCOUNTING-InvoiceRecptId", null); + + + //PVP 2.x header + httpGet.setHeader("X-PVP-EGOVTOKEN-VERSION", "2.1.2"); + httpGet.setHeader("X-PVP-USERID", "egiz@egiz.gv.at"); + httpGet.setHeader("X-PVP-GID", "gvGid"); + httpGet.setHeader("X-PVP-PARTICIPANT-ID", "AT:B:111"); + httpGet.setHeader("X-PVP-OU-GV-OU-ID", "EGIZ"); + httpGet.setHeader("X-PVP-OU", "EGIZ"); + httpGet.setHeader("X-PVP-FUNCTION", "gvFunctio"); + httpGet.setHeader("X-PVP-ROLES", "VDDS-USP-VDDS-PARTNER"); + httpGet.setHeader("X-PVP-SECCLASS", "2"); + httpGet.setHeader("X-PVP-PRINCIPAL-NAME","E-Government Innovationszentrum"); + httpGet.setHeader("X-PVP-COST-CENTER-ID", null); + httpGet.setHeader("X-PVP-INVOICE-RECPT-ID", null); + httpGet.setHeader("X-PVP-BINDING", "http"); + + StringEntity se = new StringEntity(new String(Base64.getDecoder().decode(payLoadB64), "UTF-8")); + httpGet.setEntity(se); + System.out.println("Request: " + EntityUtils.toString(httpGet.getEntity())); + + HttpResponse response = client.execute(httpGet); + + System.out.println("HTTP StatusCode: " + response.getStatusLine().getStatusCode()); + + if (response.getEntity().getContent() != null ) + System.out.println("Body: " + org.apache.commons.codec.binary.StringUtils.newStringUtf8(StreamUtils.getBytes(response.getEntity().getContent()))); + + + System.out.println("Test finished"); + + } catch (Exception e) { + e.printStackTrace(); + + } + + + } + +} |