This repository has been archived by the owner on Jun 9, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing SSL certificates to be ignored #90
* Also making keystore configurable in admin GUI.
- Loading branch information
1 parent
982d5db
commit cd23217
Showing
24 changed files
with
1,198 additions
and
319 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package se.bjurr.prnfb.http; | ||
|
||
import static com.google.common.base.Optional.fromNullable; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
|
||
import se.bjurr.prnfb.settings.PrnfbSettings; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
/** | ||
* A keystore based on the definition from the application properties.<br> | ||
* <br> | ||
* Inspired by:<br> | ||
* Philip Dodds (pdodds) https://github.com/pdodds | ||
*/ | ||
public class ClientKeyStore { | ||
|
||
private KeyStore keyStore = null; | ||
private char[] password = null; | ||
|
||
public ClientKeyStore(PrnfbSettings settings) { | ||
if (settings.getKeyStore().isPresent()) { | ||
File keyStoreFile = new File(settings.getKeyStore().get()); | ||
try { | ||
keyStore = getKeyStore(settings.getKeyStoreType()); | ||
|
||
if (settings.getKeyStorePassword().isPresent()) { | ||
password = settings.getKeyStorePassword().get().toCharArray(); | ||
} | ||
|
||
keyStore.load(new FileInputStream(keyStoreFile), password); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Unable to build keystore from " + keyStoreFile.getAbsolutePath(), e); | ||
} | ||
} | ||
} | ||
|
||
public Optional<KeyStore> getKeyStore() { | ||
return fromNullable(keyStore); | ||
} | ||
|
||
public char[] getPassword() { | ||
return password; | ||
} | ||
|
||
private KeyStore getKeyStore(String keyStoreType) throws KeyStoreException { | ||
if (keyStoreType != null) { | ||
return KeyStore.getInstance(keyStoreType); | ||
} else { | ||
return KeyStore.getInstance(KeyStore.getDefaultType()); | ||
} | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...java/se/bjurr/prnfb/listener/Invoker.java → ...ain/java/se/bjurr/prnfb/http/Invoker.java
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
Oops, something went wrong.