- public static InputStream asInputStream() {
- InputStream in = SslKeyStore.class.getResourceAsStream(filename);
- if (in == null) {
- throw new IllegalStateException("KeyStore file not found: " + filename);
+ public static InputStream asInputStream(String filename, PathType pathType) {
+ InputStream in;
+ switch (pathType) {
+ case CLASSPATH:
+ in = SslKeyStore.class.getResourceAsStream(filename);
+ if (in == null) {
+ throw new IllegalStateException("KeyStore file not found: "
+ + filename);
+ }
+ break;
+ case PATH:
+ LOG.debug("Current dir using System:"
+ + System.getProperty("user.dir"));
+ File keystorefile = new File(filename);
+ try {
+ in = new FileInputStream(keystorefile);
+ } catch (FileNotFoundException e) {
+ throw new IllegalStateException("KeyStore file not found: "
+ + filename,e);
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown path type: " + pathType);