本文整理汇总了Java中org.wildfly.security.auth.server.MechanismConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java MechanismConfiguration类的具体用法?Java MechanismConfiguration怎么用?Java MechanismConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MechanismConfiguration类属于org.wildfly.security.auth.server包,在下文中一共展示了MechanismConfiguration类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHttpAuthenticationFactory
import org.wildfly.security.auth.server.MechanismConfiguration; //导入依赖的package包/类
protected HttpAuthenticationFactory createHttpAuthenticationFactory(String contextPath) throws Exception {
SecurityDomain securityDomain = getSecurityDomain();
Map<String, String> properties = new HashMap<>();
properties.put(HttpConstants.CONFIG_LOGIN_PAGE, contextPath + "/login.html");
properties.put(HttpConstants.CONFIG_ERROR_PAGE, contextPath + "/error.html");
HttpServerAuthenticationMechanismFactory factory = doCreateHttpServerMechanismFactory(properties);
return HttpAuthenticationFactory.builder()
.setSecurityDomain(securityDomain)
.setMechanismConfigurationSelector(MechanismConfigurationSelector.constantSelector(
MechanismConfiguration.builder()
.addMechanismRealm(MechanismRealmConfiguration.builder().setRealmName("Elytron Realm").build())
.build()))
.setFactory(factory)
.build();
}
示例2: testNonDefaultRealmIdentity
import org.wildfly.security.auth.server.MechanismConfiguration; //导入依赖的package包/类
@Test
public void testNonDefaultRealmIdentity() throws Exception {
init();
ServiceName serviceName = Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName("MyDomain");
SecurityDomain domain = (SecurityDomain) services.getContainer().getService(serviceName).getValue();
Assert.assertNotNull(domain);
MechanismConfiguration mechConf = MechanismConfiguration.builder()
.addMechanismRealm(MechanismRealmConfiguration.builder().setRealmName("FileRealm").build())
.addMechanismRealm(MechanismRealmConfiguration.builder().setRealmName("PropRealm").build())
.build();
ServerAuthenticationContext context = domain.createNewAuthenticationContext(MechanismConfigurationSelector.constantSelector(mechConf));
context.setMechanismRealmName("PropRealm");
context.setAuthenticationName("[email protected]");
Assert.assertTrue(context.exists());
context.authorize();
context.succeed();
SecurityIdentity identity = context.getAuthorizedIdentity();
Assert.assertEquals("[email protected]", identity.getPrincipal().getName()); // after pre-realm-name-rewriter only
}
示例3: buildMechanismConfiguration
import org.wildfly.security.auth.server.MechanismConfiguration; //导入依赖的package包/类
static void buildMechanismConfiguration(List<ResolvedMechanismConfiguration> resolvedMechanismConfigurations, MechanismAuthenticationFactory.Builder factoryBuilder) {
ArrayList<MechanismConfigurationSelector> mechanismConfigurationSelectors = new ArrayList<>(resolvedMechanismConfigurations.size());
for (ResolvedMechanismConfiguration resolvedMechanismConfiguration : resolvedMechanismConfigurations) {
MechanismConfiguration.Builder builder = MechanismConfiguration.builder();
setPrincipalTransformer(resolvedMechanismConfiguration.preRealmPrincipalTranformer, builder::setPreRealmRewriter);
setPrincipalTransformer(resolvedMechanismConfiguration.postRealmPrincipalTransformer, builder::setPostRealmRewriter);
setPrincipalTransformer(resolvedMechanismConfiguration.finalPrincipalTransformer, builder::setFinalRewriter);
setRealmMapper(resolvedMechanismConfiguration.realmMapper, builder::setRealmMapper);
setSecurityFactory(resolvedMechanismConfiguration.securityFactory, builder::setServerCredential);
for (Entry<String, ResolvedMechanismRealmConfiguration> currentMechRealmEntry : resolvedMechanismConfiguration.mechanismRealms.entrySet()) {
MechanismRealmConfiguration.Builder mechRealmBuilder = MechanismRealmConfiguration.builder();
mechRealmBuilder.setRealmName(currentMechRealmEntry.getKey());
ResolvedMechanismRealmConfiguration resolvedMechanismRealmConfiguration = currentMechRealmEntry.getValue();
setPrincipalTransformer(resolvedMechanismRealmConfiguration.preRealmPrincipalTranformer, mechRealmBuilder::setPreRealmRewriter);
setPrincipalTransformer(resolvedMechanismRealmConfiguration.postRealmPrincipalTransformer, mechRealmBuilder::setPostRealmRewriter);
setPrincipalTransformer(resolvedMechanismRealmConfiguration.finalPrincipalTransformer, mechRealmBuilder::setFinalRewriter);
setRealmMapper(resolvedMechanismRealmConfiguration.realmMapper, mechRealmBuilder::setRealmMapper);
builder.addMechanismRealm(mechRealmBuilder.build());
}
mechanismConfigurationSelectors.add(MechanismConfigurationSelector.predicateSelector(resolvedMechanismConfiguration.selectionPredicate, builder.build()));
}
factoryBuilder.setMechanismConfigurationSelector(MechanismConfigurationSelector.aggregate(mechanismConfigurationSelectors.toArray(new MechanismConfigurationSelector[mechanismConfigurationSelectors.size()])));
}
示例4: create
import org.wildfly.security.auth.server.MechanismConfiguration; //导入依赖的package包/类
public static ChannelServer create(final Configuration configuration) throws IOException {
if (configuration == null) {
throw new IllegalArgumentException("Null configuration");
}
configuration.validate();
// Hack WFCORE-3302/REM3-303 workaround
if (firstCreate) {
firstCreate = false;
} else {
try {
// wait in case the previous socket has not closed
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
// TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();
final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
domainBuilder.addRealm("default", realm).build();
domainBuilder.setDefaultRealmName("default");
domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
SecurityDomain testDomain = domainBuilder.build();
SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder()
.setSecurityDomain(testDomain)
.setMechanismConfigurationSelector(mechanismInformation -> "ANONYMOUS".equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null)
.setFactory(new AnonymousServerFactory())
.build();
System.out.println(configuration.getBindAddress());
AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);
return new ChannelServer(endpoint, null, streamServer);
}
示例5: create
import org.wildfly.security.auth.server.MechanismConfiguration; //导入依赖的package包/类
public static ChannelServer create(final Configuration configuration) throws IOException {
if (configuration == null) {
throw new IllegalArgumentException("Null configuration");
}
configuration.validate();
// Hack WFCORE-3302/REM3-303 workaround
if (firstCreate) {
firstCreate = false;
} else {
try {
// wait in case the previous socket has not closed
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
// TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();
final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
realm.setPasswordMap("bob", ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, "pass".toCharArray()));
domainBuilder.addRealm("default", realm).build();
domainBuilder.setDefaultRealmName("default");
domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
SecurityDomain testDomain = domainBuilder.build();
SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder()
.setSecurityDomain(testDomain)
.setMechanismConfigurationSelector(mechanismInformation -> {
switch (mechanismInformation.getMechanismName()) {
case "ANONYMOUS":
case "PLAIN": {
return MechanismConfiguration.EMPTY;
}
default: return null;
}
})
.setFactory(SaslFactories.getElytronSaslServerFactory())
.build();
AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);
return new ChannelServer(endpoint, streamServer);
}