Commit fd24e652 by nixonrodrigues

ATLAS-3995 : Atlas should support additional keystore/truststores types besides JKS.

parent 39892854
...@@ -32,9 +32,11 @@ public final class SecurityProperties { ...@@ -32,9 +32,11 @@ public final class SecurityProperties {
public static final String KEYSTORE_FILE_KEY = "keystore.file"; public static final String KEYSTORE_FILE_KEY = "keystore.file";
public static final String DEFAULT_KEYSTORE_FILE_LOCATION = "target/atlas.keystore"; public static final String DEFAULT_KEYSTORE_FILE_LOCATION = "target/atlas.keystore";
public static final String KEYSTORE_PASSWORD_KEY = "keystore.password"; public static final String KEYSTORE_PASSWORD_KEY = "keystore.password";
public static final String KEYSTORE_TYPE = "keystore.type";
public static final String TRUSTSTORE_FILE_KEY = "truststore.file"; public static final String TRUSTSTORE_FILE_KEY = "truststore.file";
public static final String DEFATULT_TRUSTORE_FILE_LOCATION = "target/atlas.keystore"; public static final String DEFATULT_TRUSTORE_FILE_LOCATION = "target/atlas.keystore";
public static final String TRUSTSTORE_PASSWORD_KEY = "truststore.password"; public static final String TRUSTSTORE_PASSWORD_KEY = "truststore.password";
public static final String TRUSTSTORE_TYPE = "truststore.type";
public static final String SERVER_CERT_PASSWORD_KEY = "password"; public static final String SERVER_CERT_PASSWORD_KEY = "password";
public static final String CLIENT_AUTH_KEY = "client.auth.enabled"; public static final String CLIENT_AUTH_KEY = "client.auth.enabled";
public static final String CERT_STORES_CREDENTIAL_PROVIDER_PATH = "cert.stores.credential.provider.path"; public static final String CERT_STORES_CREDENTIAL_PROVIDER_PATH = "cert.stores.credential.provider.path";
......
...@@ -69,6 +69,8 @@ import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_FILE_KEY; ...@@ -69,6 +69,8 @@ import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_FILE_KEY;
import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_PASSWORD_KEY; import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_PASSWORD_KEY;
import static org.apache.atlas.security.SecurityProperties.ATLAS_SSL_EXCLUDE_PROTOCOLS; import static org.apache.atlas.security.SecurityProperties.ATLAS_SSL_EXCLUDE_PROTOCOLS;
import static org.apache.atlas.security.SecurityProperties.DEFAULT_EXCLUDE_PROTOCOLS; import static org.apache.atlas.security.SecurityProperties.DEFAULT_EXCLUDE_PROTOCOLS;
import static org.apache.atlas.security.SecurityProperties.KEYSTORE_TYPE;
import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_TYPE;
import static org.apache.atlas.security.SecurityUtil.getPassword; import static org.apache.atlas.security.SecurityUtil.getPassword;
...@@ -101,10 +103,12 @@ public class SecureEmbeddedServer extends EmbeddedServer { ...@@ -101,10 +103,12 @@ public class SecureEmbeddedServer extends EmbeddedServer {
} }
SslContextFactory sslContextFactory = new SslContextFactory(); SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreType(config.getString(KEYSTORE_TYPE , ATLAS_KEYSTORE_FILE_TYPE_DEFAULT));
sslContextFactory.setKeyStorePath(config.getString(KEYSTORE_FILE_KEY, sslContextFactory.setKeyStorePath(config.getString(KEYSTORE_FILE_KEY,
System.getProperty(KEYSTORE_FILE_KEY, DEFAULT_KEYSTORE_FILE_LOCATION))); System.getProperty(KEYSTORE_FILE_KEY, DEFAULT_KEYSTORE_FILE_LOCATION)));
sslContextFactory.setKeyStorePassword(getPassword(config, KEYSTORE_PASSWORD_KEY)); sslContextFactory.setKeyStorePassword(getPassword(config, KEYSTORE_PASSWORD_KEY));
sslContextFactory.setKeyManagerPassword(getPassword(config, SERVER_CERT_PASSWORD_KEY)); sslContextFactory.setKeyManagerPassword(getPassword(config, SERVER_CERT_PASSWORD_KEY));
sslContextFactory.setTrustStoreType(config.getString(TRUSTSTORE_TYPE , ATLAS_TRUSTSTORE_FILE_TYPE_DEFAULT));
sslContextFactory.setTrustStorePath(config.getString(TRUSTSTORE_FILE_KEY, sslContextFactory.setTrustStorePath(config.getString(TRUSTSTORE_FILE_KEY,
System.getProperty(TRUSTSTORE_FILE_KEY, DEFATULT_TRUSTORE_FILE_LOCATION))); System.getProperty(TRUSTSTORE_FILE_KEY, DEFATULT_TRUSTORE_FILE_LOCATION)));
sslContextFactory.setTrustStorePassword(getPassword(config, TRUSTSTORE_PASSWORD_KEY)); sslContextFactory.setTrustStorePassword(getPassword(config, TRUSTSTORE_PASSWORD_KEY));
...@@ -198,7 +202,7 @@ public class SecureEmbeddedServer extends EmbeddedServer { ...@@ -198,7 +202,7 @@ public class SecureEmbeddedServer extends EmbeddedServer {
in = getFileInputStream(keyStoreFile); in = getFileInputStream(keyStoreFile);
if (in != null) { if (in != null) {
KeyStore keyStore = KeyStore.getInstance(ATLAS_KEYSTORE_FILE_TYPE_DEFAULT); KeyStore keyStore = KeyStore.getInstance(getConfiguration().getString(KEYSTORE_TYPE , ATLAS_KEYSTORE_FILE_TYPE_DEFAULT));
keyStore.load(in, keyStoreFilepwd.toCharArray()); keyStore.load(in, keyStoreFilepwd.toCharArray());
...@@ -251,7 +255,7 @@ public class SecureEmbeddedServer extends EmbeddedServer { ...@@ -251,7 +255,7 @@ public class SecureEmbeddedServer extends EmbeddedServer {
in = getFileInputStream(truststoreFile); in = getFileInputStream(truststoreFile);
if (in != null) { if (in != null) {
KeyStore trustStore = KeyStore.getInstance(ATLAS_TRUSTSTORE_FILE_TYPE_DEFAULT); KeyStore trustStore = KeyStore.getInstance(getConfiguration().getString(TRUSTSTORE_TYPE , ATLAS_TRUSTSTORE_FILE_TYPE_DEFAULT));
trustStore.load(in, trustStoreFilepwd.toCharArray()); trustStore.load(in, trustStoreFilepwd.toCharArray());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment