Created
June 30, 2016 15:10
-
-
Save velfundert/66e179bffec2712bc949eed4bba9c1af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Last sertifikat fra fil, og bygg klient: | |
String passord = "password"; | |
InputStream sertifikat = new FileInputStream("cert.p12"); | |
DigipostUserDocumentClient client = new Builder(AVSENDERS_KONTOID, sertifikat, passord) | |
.serviceEndpoint(new URI("https://...")) | |
.build(); | |
/* ********* */ | |
// Last sertifikat fra keystore (populert med keytool), og bygg klient: | |
String keyStorePassord = "KeystorePassord" | |
String keyPassord = "passord for sertifikat"; | |
InputStream sertifikat = new FileInputStream("keystore.jks"); | |
KeyStore keyStore = KeyStore.getInstance("JKS"); | |
keyStore.load(sertifikat, keyStorePassord.toCharArray()); | |
sertifikat.close(); | |
String onlyKeyAlias = keyStore.aliases().nextElement(); | |
PrivateKey key = (PrivateKey) keyStore.getKey(onlyKeyAlias, keyPassord.toCharArray()); | |
DigipostUserDocumentClient client = new Builder(AVSENDERS_KONTOID, key) | |
.serviceEndpoint(new URI("https://...")) | |
.build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment