Search in sources :

Example 1 with ServiceLoaderSaslServerFactory

use of org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory in project jboss-remoting by jboss-remoting.

the class ConnectionCloseTestCase method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    final WildFlyElytronProvider provider = new WildFlyElytronProvider();
    Security.addProvider(provider);
    providerName = provider.getName();
    endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(ConnectionCloseTestCase.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SASL_MECHANISMS, Sequence.of("CRAM-MD5"), Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
}
Also used : ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) InetSocketAddress(java.net.InetSocketAddress) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) WildFlyElytronProvider(org.wildfly.security.WildFlyElytronProvider) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) PasswordFactory(org.wildfly.security.password.PasswordFactory) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) BeforeClass(org.junit.BeforeClass)

Example 2 with ServiceLoaderSaslServerFactory

use of org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory in project jboss-remoting by jboss-remoting.

the class RemoteChannelCloseTest method create.

@BeforeClass
public static void create() throws Exception {
    final WildFlyElytronProvider provider = new WildFlyElytronProvider();
    Security.addProvider(provider);
    providerName = provider.getName();
    endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(RemoteChannelCloseTest.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
}
Also used : ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) InetSocketAddress(java.net.InetSocketAddress) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) WildFlyElytronProvider(org.wildfly.security.WildFlyElytronProvider) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) PasswordFactory(org.wildfly.security.password.PasswordFactory) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) BeforeClass(org.junit.BeforeClass)

Example 3 with ServiceLoaderSaslServerFactory

use of org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory in project jboss-remoting by jboss-remoting.

the class RemoteChannelTest method create.

@BeforeClass
public static void create() throws Exception {
    endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(RemoteChannelTest.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
}
Also used : ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) PasswordFactory(org.wildfly.security.password.PasswordFactory) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) InetSocketAddress(java.net.InetSocketAddress) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) BeforeClass(org.junit.BeforeClass)

Example 4 with ServiceLoaderSaslServerFactory

use of org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory in project jboss-remoting by jboss-remoting.

the class RemoteServiceWithPredicateTest method create.

/**
 * Create an Endpoint and an AcceptingChannel<StreamConnection> to receive connection requests
 * @throws Exception
 */
@BeforeClass
public static void create() throws Exception {
    final WildFlyElytronProvider provider = new WildFlyElytronProvider();
    Security.addProvider(provider);
    providerName = provider.getName();
    endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(RemoteServiceWithPredicateTest.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
}
Also used : ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) InetSocketAddress(java.net.InetSocketAddress) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) WildFlyElytronProvider(org.wildfly.security.WildFlyElytronProvider) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) PasswordFactory(org.wildfly.security.password.PasswordFactory) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) BeforeClass(org.junit.BeforeClass)

Example 5 with ServiceLoaderSaslServerFactory

use of org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory in project jboss-remoting by jboss-remoting.

the class RemoteSslChannelTest method create.

@BeforeClass
public static void create() throws IOException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException {
    SslHelper.setKeyStoreAndTrustStore();
    endpoint = Endpoint.builder().setEndpointName("test").build();
    NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
    final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
    final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
    domainBuilder.addRealm("mainRealm", mainRealm).build();
    domainBuilder.setDefaultRealmName("mainRealm");
    domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
    final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
    mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
    final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(RemoteSslChannelTest.class.getClassLoader());
    final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
    builder.setSecurityDomain(domainBuilder.build());
    builder.setFactory(saslServerFactory);
    builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
    final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
    streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.TRUE, Options.SASL_MECHANISMS, Sequence.of("CRAM-MD5")), saslAuthenticationFactory, SSLContext.getDefault());
}
Also used : ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) SaslAuthenticationFactory(org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory) SimpleMapBackedSecurityRealm(org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm) PasswordFactory(org.wildfly.security.password.PasswordFactory) SaslServerFactory(javax.security.sasl.SaslServerFactory) ServiceLoaderSaslServerFactory(org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory) InetSocketAddress(java.net.InetSocketAddress) NetworkServerProvider(org.jboss.remoting3.spi.NetworkServerProvider) ClearPasswordSpec(org.wildfly.security.password.spec.ClearPasswordSpec) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) BeforeClass(org.junit.BeforeClass)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)10 SaslServerFactory (javax.security.sasl.SaslServerFactory)10 NetworkServerProvider (org.jboss.remoting3.spi.NetworkServerProvider)10 SimpleMapBackedSecurityRealm (org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm)10 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)10 SaslAuthenticationFactory (org.wildfly.security.auth.server.sasl.SaslAuthenticationFactory)10 PasswordFactory (org.wildfly.security.password.PasswordFactory)10 ClearPasswordSpec (org.wildfly.security.password.spec.ClearPasswordSpec)10 ServiceLoaderSaslServerFactory (org.wildfly.security.sasl.util.ServiceLoaderSaslServerFactory)10 BeforeClass (org.junit.BeforeClass)6 WildFlyElytronProvider (org.wildfly.security.WildFlyElytronProvider)4 Test (org.junit.Test)3 Closeable (java.io.Closeable)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Channel (org.jboss.remoting3.Channel)2 Connection (org.jboss.remoting3.Connection)2 Endpoint (org.jboss.remoting3.Endpoint)2 OpenListener (org.jboss.remoting3.OpenListener)2 Registration (org.jboss.remoting3.Registration)2