use of org.jboss.security.JBossJSSESecurityDomain in project wildfly by wildfly.
the class SecurityDomainAdd method createJSSESecurityDomain.
private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) throws OperationFailedException {
node = peek(node, JSSE, CLASSIC);
if (node == null) {
return null;
}
final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
public void setKeyStorePassword(String value) throws Exception {
jsseSecurityDomain.setKeyStorePassword(value);
}
public void setKeyStoreType(String value) {
jsseSecurityDomain.setKeyStoreType(value);
}
public void setKeyStoreURL(String value) throws IOException {
jsseSecurityDomain.setKeyStoreURL(value);
}
public void setKeyStoreProvider(String value) {
jsseSecurityDomain.setKeyStoreProvider(value);
}
public void setKeyStoreProviderArgument(String value) {
jsseSecurityDomain.setKeyStoreProviderArgument(value);
}
});
processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
public void setKeyStorePassword(String value) throws Exception {
jsseSecurityDomain.setTrustStorePassword(value);
}
public void setKeyStoreType(String value) {
jsseSecurityDomain.setTrustStoreType(value);
}
public void setKeyStoreURL(String value) throws IOException {
jsseSecurityDomain.setTrustStoreURL(value);
}
public void setKeyStoreProvider(String value) {
jsseSecurityDomain.setTrustStoreProvider(value);
}
public void setKeyStoreProviderArgument(String value) {
jsseSecurityDomain.setTrustStoreProviderArgument(value);
}
});
processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {
public void setKeyManagerFactoryAlgorithm(String value) {
jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
}
public void setKeyManagerFactoryProvider(String value) {
jsseSecurityDomain.setKeyManagerFactoryProvider(value);
}
});
processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
public void setKeyManagerFactoryAlgorithm(String value) {
jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
}
public void setKeyManagerFactoryProvider(String value) {
jsseSecurityDomain.setTrustManagerFactoryProvider(value);
}
});
String value;
if (node.hasDefined(CLIENT_ALIAS)) {
value = JSSEResourceDefinition.CLIENT_ALIAS.resolveModelAttribute(context, node).asString();
jsseSecurityDomain.setClientAlias(value);
}
if (node.hasDefined(SERVER_ALIAS)) {
value = JSSEResourceDefinition.SERVER_ALIAS.resolveModelAttribute(context, node).asString();
jsseSecurityDomain.setServerAlias(value);
}
if (node.hasDefined(CLIENT_AUTH)) {
boolean clientAuth = JSSEResourceDefinition.CLIENT_AUTH.resolveModelAttribute(context, node).asBoolean();
jsseSecurityDomain.setClientAuth(clientAuth);
}
if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
value = JSSEResourceDefinition.SERVICE_AUTH_TOKEN.resolveModelAttribute(context, node).asString();
try {
jsseSecurityDomain.setServiceAuthToken(value);
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
}
}
if (node.hasDefined(CIPHER_SUITES)) {
value = JSSEResourceDefinition.CIPHER_SUITES.resolveModelAttribute(context, node).asString();
jsseSecurityDomain.setCipherSuites(value);
}
if (node.hasDefined(PROTOCOLS)) {
value = JSSEResourceDefinition.PROTOCOLS.resolveModelAttribute(context, node).asString();
jsseSecurityDomain.setProtocols(value);
}
if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
Properties properties = new Properties();
properties.putAll(JSSEResourceDefinition.ADDITIONAL_PROPERTIES.unwrap(context, node));
jsseSecurityDomain.setAdditionalProperties(properties);
}
return jsseSecurityDomain;
}
use of org.jboss.security.JBossJSSESecurityDomain in project teiid by teiid.
the class JWTBearerTokenLoginModule method loadKeystore.
private static void loadKeystore(String keystoreURL, String keystorePassword, String keystoreType, String password) throws Exception, IOException {
if (securityDomain == null) {
securityDomain = new JBossJSSESecurityDomain("JWTBearer");
securityDomain.setKeyStorePassword(keystorePassword);
securityDomain.setKeyStoreType(keystoreType == null ? "JKS" : keystoreType);
securityDomain.setKeyStoreURL(keystoreURL);
securityDomain.setServiceAuthToken(password);
securityDomain.reloadKeyAndTrustStore();
}
}
use of org.jboss.security.JBossJSSESecurityDomain in project wildfly by wildfly.
the class WebSecurityCERTTestCase method getHttpsClient.
private static CloseableHttpClient getHttpsClient(String alias) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain("client-cert");
jsseSecurityDomain.setKeyStorePassword("changeit");
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
URL keystore = tccl.getResource("security/client.keystore");
jsseSecurityDomain.setKeyStoreURL(keystore.getPath());
jsseSecurityDomain.setClientAlias(alias);
jsseSecurityDomain.reloadKeyAndTrustStore();
KeyManager[] keyManagers = jsseSecurityDomain.getKeyManagers();
TrustManager[] trustManagers = jsseSecurityDomain.getTrustManagers();
ctx.init(keyManagers, trustManagers, null);
HostnameVerifier verifier = (string, ssls) -> true;
//SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(ctx, verifier);
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", ssf).build();
HttpClientConnectionManager ccm = new BasicHttpClientConnectionManager(registry);
return HttpClientBuilder.create().setSSLSocketFactory(ssf).setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionManager(ccm).build();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
Aggregations