当前位置: 首页>>代码示例>>Java>>正文


Java MechanismConfiguration类代码示例

本文整理汇总了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();
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:20,代码来源:AbstractHttpServerMechanismTest.java

示例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
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:DomainTestCase.java

示例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()])));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:AuthenticationFactoryDefinitions.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:40,代码来源:ChannelServer.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:48,代码来源:ChannelServer.java


注:本文中的org.wildfly.security.auth.server.MechanismConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。