summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-01 15:26:19 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-01 15:26:19 +0200
commita33be2d176e30e929ad043f9a31b2f55f4738202 (patch)
tree6207373f757c38bba9ed883364ac1da36f400881
parent63d74e5db5a38672c221467d51a737bc019df38d (diff)
downloadEAAF-Components-a33be2d176e30e929ad043f9a31b2f55f4738202.tar.gz
EAAF-Components-a33be2d176e30e929ad043f9a31b2f55f4738202.tar.bz2
EAAF-Components-a33be2d176e30e929ad043f9a31b2f55f4738202.zip
update resource loading implementation in HttpClientFactory.java
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/HttpClientFactory.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/HttpClientFactory.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/HttpClientFactory.java
index bfbe6ae2..d1cde6fa 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/HttpClientFactory.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/HttpClientFactory.java
@@ -1,8 +1,7 @@
package at.gv.egiz.eaaf.core.impl.utils;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -38,6 +37,8 @@ import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
import at.gv.egiz.eaaf.core.exceptions.EAAFConfigurationException;
@@ -45,6 +46,7 @@ import at.gv.egiz.eaaf.core.exceptions.EAAFConfigurationException;
public class HttpClientFactory implements IHttpClientFactory {
private static final Logger log = LoggerFactory.getLogger(HttpClientFactory.class);
@Autowired(required=true) private IConfiguration basicConfig;
+ @Autowired(required=true) ResourceLoader resourceLoader;
public static final String PROP_CONFIG_CLIENT_HTTP_CONNECTION_POOL_USE = "client.http.connection.pool.use";
public static final String PROP_CONFIG_CLIENT_HTTP_CONNECTION_POOL_MAXTOTAL = "client.http.connection.pool.maxtotal";
@@ -270,17 +272,13 @@ public class HttpClientFactory implements IHttpClientFactory {
log.debug("Read keyStore path: {} from configuration", localKeyStorePath);
if (StringUtils.isNotEmpty(localKeyStorePath)) {
- String absFilePath = FileUtils.makeAbsoluteURL(localKeyStorePath, basicConfig.getConfigurationRootDirectory());
-
- if (absFilePath.startsWith("file:")) {
- absFilePath = absFilePath.substring("file:".length());
-
- }
-
- final File keyStoreFile = new File(absFilePath);
+ final String absFilePath = FileUtils.makeAbsoluteURL(localKeyStorePath, basicConfig.getConfigurationRootDirectory());
+ final Resource ressource = resourceLoader.getResource(absFilePath);
+ final InputStream is = ressource.getInputStream();
log.trace("Load keyStore: {} with password: {}", absFilePath, keyStorePassword);
- clientStore.load(new FileInputStream(keyStoreFile), keyStorePassword.toCharArray());
-
+ clientStore.load(is, keyStorePassword.toCharArray());
+ is.close();
+
return clientStore;
} else {