package at.gv.util.demo; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; 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) throws UnsupportedEncodingException { String b64AuthBlock = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+CjxzbDpDcmVhdGVYTUxTaWduYXR1cmVSZXF1ZXN0IHhtbG5zOmRzaWc9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyMnIHhtbG5zOnNsPSdodHRwOi8vd3d3LmJ1ZXJnZXJrYXJ0ZS5hdC9uYW1lc3BhY2VzL3NlY3VyaXR5bGF5ZXIvMS4yIyc+CiA8c2w6S2V5Ym94SWRlbnRpZmllcj5TZWN1cmVTaWduYXR1cmVLZXlwYWlyPC9zbDpLZXlib3hJZGVudGlmaWVyPgogPHNsOkRhdGFPYmplY3RJbmZvIFN0cnVjdHVyZT0nZGV0YWNoZWQnPgogIDxzbDpEYXRhT2JqZWN0IFJlZmVyZW5jZT0nJy8+CjxzbDpUcmFuc2Zvcm1zSW5mbz4NCgk8ZHNpZzpUcmFuc2Zv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O8cmdlcnBvcnRhbCAtIE5ldWVyIE5hbWU8L3NhbWw6QXR0cmlidXRlVmFsdWU+CiAgIDwvc2FtbDpBdHRyaWJ1dGU+CiA8L3NhbWw6QXR0cmlidXRlU3RhdGVtZW50Pgo8L3NhbWw6QXNzZXJ0aW9uPjwvc2w6WE1MQ29udGVudD4KICA8L3NsOlNpZ25hdHVyZUVudmlyb25tZW50PgogIDxzbDpTaWduYXR1cmVMb2NhdGlvbiB4bWxuczpzYW1sPSd1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoxLjA6YXNzZXJ0aW9uJyBJbmRleD0nMic+L3NhbWw6QXNzZXJ0aW9uPC9zbDpTaWduYXR1cmVMb2NhdGlvbj4KIDwvc2w6U2lnbmF0dXJlSW5mbz4KPC9zbDpDcmVhdGVYTUxTaWduYXR1cmVSZXF1ZXN0Pg=="; byte[] authBlock = Base64.getDecoder().decode(b64AuthBlock); new String(authBlock, "UTF-8"); new String(authBlock, "ISO-8859-1"); new String(authBlock, "Cp850"); new String(authBlock, "Cp1252"); 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+DQoJCTxuczM6TGlzdE1hbmRhdGVzUmVxdWVzdCB4bWxuczpuczM9Imh0dHA6Ly9lYWkuYnJ6Lmd2LmF0L3NlcnZpY2VzL3ZkZHMvc3luYy1tc2dzIiB4bWxucz0iaHR0cDovL2VhaS5icnouZ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CgkJCQkJPG5zMzpTZWFyY2hDcml0ZXJpYT4NCgkJCQkJCTxuczM6UmVwcmVzZW50YXRpdmVJRD4NCgkJCQkJCQk8bnM1OlZhbHVlPmdkNHU0V05EalYzeEJZTWN1Qm1qMnZ3aEg4OD08L25zNTpWYWx1ZT4NCgkJCQkJCQk8bnM1OlR5cGU+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 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(); } } }