use of com.unboundid.util.ssl.KeyStoreKeyManager in project cdap by caskdata.
the class ExternalLDAPAuthenticationServerSSLTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
URL certUrl = ExternalLDAPAuthenticationServerSSLTest.class.getClassLoader().getResource("cert.jks");
Assert.assertNotNull(certUrl);
String authHandlerConfigBase = Constants.Security.AUTH_HANDLER_CONFIG_BASE;
CConfiguration cConf = CConfiguration.create();
SConfiguration sConf = SConfiguration.create();
cConf.set(Constants.Security.AUTH_SERVER_BIND_ADDRESS, "127.0.0.1");
cConf.set(Constants.Security.SSL.EXTERNAL_ENABLED, "true");
cConf.set(Constants.Security.AuthenticationServer.SSL_PORT, "0");
cConf.set(authHandlerConfigBase.concat("useLdaps"), "true");
cConf.set(authHandlerConfigBase.concat("ldapsVerifyCertificate"), "false");
sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PATH, certUrl.getPath());
configuration = cConf;
sConfiguration = sConf;
String keystorePassword = sConf.get(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PASSWORD);
KeyStoreKeyManager keyManager = new KeyStoreKeyManager(certUrl.getFile(), keystorePassword.toCharArray());
SSLUtil sslUtil = new SSLUtil(keyManager, new TrustAllTrustManager());
ldapListenerConfig = InMemoryListenerConfig.createLDAPSConfig("LDAP", InetAddress.getByName("127.0.0.1"), ldapPort, sslUtil.createSSLServerSocketFactory(), sslUtil.createSSLSocketFactory());
testServer = new ExternalLDAPAuthenticationServerSSLTest();
testServer.setup();
}
use of com.unboundid.util.ssl.KeyStoreKeyManager in project coprhd-controller by CoprHD.
the class LDAPServer method getInMemoryListenerConfigs.
private List<InMemoryListenerConfig> getInMemoryListenerConfigs() throws LDAPException, IOException, GeneralSecurityException, FileOperationFailedException {
// Creates the ldap configuration of the in memory ldap server.
int ldapPort = this._ldapListenPort != 0 ? this._ldapListenPort : DEFAULT_LDAP_LISTEN_PORT;
InMemoryListenerConfig ldapListenerConfig = InMemoryListenerConfig.createLDAPConfig(_listenerName, ldapPort);
// Creates the ldaps configuration of the in memory ldap server.
int ldapsPort = this._ldapsListenPort != 0 ? this._ldapsListenPort : DEFAULT_LDAPS_LISTEN_PORT;
_log.debug("Ldap port {} and Ldaps port {}", ldapPort, ldapsPort);
InputStream propFile = LDAPServer.class.getResourceAsStream(DEFAULT_LDAP_SERVER_PROPERTIES);
Properties prop = new Properties();
prop.load(propFile);
String keyStorePassword = prop.getProperty("keyStorePassword");
String keyStoreAlias = prop.getProperty("keyStoreAlias");
String keyStoreType = prop.getProperty("keyStoreType");
final SSLUtil serverSSLUtil = new SSLUtil(new KeyStoreKeyManager(createKeystoreFile(), keyStorePassword.toCharArray(), keyStoreType, keyStoreAlias), null);
final SSLUtil clientSSLUtil = new SSLUtil(new TrustAllTrustManager());
String secureListenerName = "Secure_" + _listenerName;
InMemoryListenerConfig ldapsListenerConfig = InMemoryListenerConfig.createLDAPSConfig(secureListenerName, null, ldapsPort, serverSSLUtil.createSSLServerSocketFactory(), clientSSLUtil.createSSLSocketFactory());
_log.info("Listener config {} and secure listener config {}", ldapListenerConfig.getListenerName(), ldapsListenerConfig.getListenerName());
// Adds both ldap and ldaps configuration to the list of listener configs of the
// in memory ldap server.
List<InMemoryListenerConfig> listenerConfigs = new ArrayList<InMemoryListenerConfig>();
listenerConfigs.add(ldapListenerConfig);
listenerConfigs.add(ldapsListenerConfig);
return listenerConfigs;
}
use of com.unboundid.util.ssl.KeyStoreKeyManager in project admin-console-beta by connexta.
the class TestLdapServer method getServerSSLContext.
SSLContext getServerSSLContext() {
try {
char[] keyStorePassword = "changeit".toCharArray();
String keystore = getClass().getResource("/serverKeystore.jks").getFile();
KeyStoreKeyManager keyManager = new KeyStoreKeyManager(keystore, keyStorePassword, "JKS", getHostname());
String truststore = getClass().getResource("/serverTruststore.jks").getFile();
TrustStoreTrustManager trustManager = new TrustStoreTrustManager(truststore, keyStorePassword, null, false);
return new SSLUtil(keyManager, trustManager).createSSLContext();
} catch (GeneralSecurityException e) {
fail(e.getMessage());
}
return null;
}
Aggregations