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


Java PrincipalResolver类代码示例

本文整理汇总了Java中org.apereo.cas.authentication.principal.PrincipalResolver的典型用法代码示例。如果您正苦于以下问题:Java PrincipalResolver类的具体用法?Java PrincipalResolver怎么用?Java PrincipalResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrincipalResolver类属于org.apereo.cas.authentication.principal包,在下文中一共展示了PrincipalResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: x509SerialNumberPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver x509SerialNumberPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SerialNumberPrincipalResolver r;
    final int radix = x509.getPrincipalSNRadix();
    if (Character.MIN_RADIX <= radix && radix <= Character.MAX_RADIX) {
        if (radix == HEX) {
            r = new X509SerialNumberPrincipalResolver(radix, x509.isPrincipalHexSNZeroPadding());
        } else {
            r = new X509SerialNumberPrincipalResolver(radix, false);
        }
    } else {
        r = new X509SerialNumberPrincipalResolver();
    }
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(x509.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(x509.getPrincipal().isReturnNull());
    r.setPrincipalFactory(x509PrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:X509AuthenticationConfiguration.java

示例2: configureAuthenticationExecutionPlan

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Override
public void configureAuthenticationExecutionPlan(final AuthenticationEventExecutionPlan plan) {
    PrincipalResolver resolver = personDirectoryPrincipalResolver;
    if (casProperties.getAuthn().getX509().getPrincipalType() != null) {
        switch (casProperties.getAuthn().getX509().getPrincipalType()) {
            case SERIAL_NO:
                resolver = x509SerialNumberPrincipalResolver();
                break;
            case SERIAL_NO_DN:
                resolver = x509SerialNumberAndIssuerDNPrincipalResolver();
                break;
            case SUBJECT:
                resolver = x509SubjectPrincipalResolver();
                break;
            case SUBJECT_ALT_NAME:
                resolver = x509SubjectAlternativeNameUPNPrincipalResolver();
                break;
            default:
                resolver = x509SubjectDNPrincipalResolver();
                break;
        }
    }
    
    plan.registerAuthenticationHandlerWithPrincipalResolver(x509CredentialsAuthenticationHandler(), resolver);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:X509AuthenticationConfiguration.java

示例3: resolvePrincipal

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
/**
 * Resolve principal.
 *
 * @param handler    the handler name
 * @param resolver   the resolver
 * @param credential the credential
 * @param principal  the current authenticated principal from a handler, if any.
 * @return the principal
 */
protected Principal resolvePrincipal(final AuthenticationHandler handler, final PrincipalResolver resolver,
                                     final Credential credential, final Principal principal) {
    if (resolver.supports(credential)) {
        try {
            final Principal p = resolver.resolve(credential, principal, handler);
            LOGGER.debug("[{}] resolved [{}] from [{}]", resolver, p, credential);
            return p;
        } catch (final Exception e) {
            LOGGER.error("[{}] failed to resolve principal from [{}]", resolver, credential, e);
        }
    } else {
        LOGGER.warn(
                "[{}] is configured to use [{}] but it does not support [{}], which suggests a configuration problem.",
                handler.getName(), resolver, credential);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:27,代码来源:AbstractAuthenticationManager.java

示例4: verifyAuthenticateAllFailure

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Test
public void verifyAuthenticateAllFailure() throws Exception {
    final Map<AuthenticationHandler, PrincipalResolver> map = new LinkedHashMap<>();
    map.put(newMockHandler(false), null);
    map.put(newMockHandler(false), null);

    final PolicyBasedAuthenticationManager manager = new PolicyBasedAuthenticationManager(getAuthenticationExecutionPlan(map),
            mockServicesManager(),
            new AllAuthenticationPolicy());

    this.thrown.expect(AuthenticationException.class);
    this.thrown.expectMessage("2 errors, 0 successes");

    manager.authenticate(transaction);

    fail("Should have thrown authentication exception");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:PolicyBasedAuthenticationManagerTests.java

示例5: verifyAuthenticateRequiredHandlerFailure

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Test
public void verifyAuthenticateRequiredHandlerFailure() throws Exception {
    final Map<AuthenticationHandler, PrincipalResolver> map = new LinkedHashMap<>();
    map.put(newMockHandler(HANDLER_A, true), null);
    map.put(newMockHandler(HANDLER_B, false), null);

    final PolicyBasedAuthenticationManager manager = new PolicyBasedAuthenticationManager(getAuthenticationExecutionPlan(map),
            mockServicesManager(), new RequiredHandlerAuthenticationPolicy(HANDLER_B));

    this.thrown.expect(AuthenticationException.class);
    this.thrown.expectMessage("1 errors, 1 successes");

    manager.authenticate(transaction);

    fail("Should have thrown AbstractAuthenticationException");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:PolicyBasedAuthenticationManagerTests.java

示例6: trustedPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver trustedPrincipalResolver() {
    final ChainingPrincipalResolver resolver = new ChainingPrincipalResolver();

    final PrincipalBearingPrincipalResolver bearingPrincipalResolver = new PrincipalBearingPrincipalResolver();
    bearingPrincipalResolver.setAttributeRepository(this.attributeRepository);
    bearingPrincipalResolver.setPrincipalAttributeName(casProperties.getAuthn().getTrusted().getPrincipalAttribute());
    bearingPrincipalResolver.setReturnNullIfNoAttributes(casProperties.getAuthn().getTrusted().isReturnNull());
    bearingPrincipalResolver.setPrincipalFactory(trustedPrincipalFactory());
    
    resolver.setChain(Arrays.asList(bearingPrincipalResolver, new EchoingPrincipalResolver()));
    return resolver;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:TrustedAuthenticationConfiguration.java

示例7: spnegoPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver spnegoPrincipalResolver() {
    final SpnegoProperties spnegoProperties = casProperties.getAuthn().getSpnego();
    final SpnegoPrincipalResolver r = new SpnegoPrincipalResolver();
    r.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(spnegoProperties.getPrincipalTransformation()));
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(spnegoProperties.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(spnegoProperties.getPrincipal().isReturnNull());
    r.setPrincipalFactory(spnegoPrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:SpnegoConfiguration.java

示例8: adfsPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver adfsPrincipalResolver() {
    final WsFederationDelegationProperties wsfed = casProperties.getAuthn().getWsfed();
    final WsFederationCredentialsToPrincipalResolver r = new WsFederationCredentialsToPrincipalResolver();
    r.setConfiguration(wsFedConfig());
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(wsfed.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(wsfed.getPrincipal().isReturnNull());
    r.setPrincipalFactory(adfsPrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:WsFedAuthenticationEventExecutionPlanConfiguration.java

示例9: personDirectoryPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Autowired
@RefreshScope
@Bean
public PrincipalResolver personDirectoryPrincipalResolver(@Qualifier("attributeRepository") final IPersonAttributeDao attributeRepository,
                                                          @Qualifier("principalFactory") final PrincipalFactory principalFactory) {
    final SurrogatePrincipalResolver bean = new SurrogatePrincipalResolver();
    bean.setAttributeRepository(attributeRepository);
    bean.setPrincipalAttributeName(casProperties.getPersonDirectory().getPrincipalAttribute());
    bean.setReturnNullIfNoAttributes(casProperties.getPersonDirectory().isReturnNull());
    bean.setPrincipalFactory(principalFactory);
    return bean;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:SurrogateAuthenticationConfiguration.java

示例10: x509SubjectPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver x509SubjectPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SubjectPrincipalResolver r = new X509SubjectPrincipalResolver(x509.getPrincipalDescriptor());
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(x509.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(x509.getPrincipal().isReturnNull());
    r.setPrincipalFactory(x509PrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:X509AuthenticationConfiguration.java

示例11: x509SubjectDNPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver x509SubjectDNPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SubjectDNPrincipalResolver r = new X509SubjectDNPrincipalResolver();
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(x509.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(x509.getPrincipal().isReturnNull());
    r.setPrincipalFactory(x509PrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:X509AuthenticationConfiguration.java

示例12: x509SubjectAlternativeNameUPNPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Bean
@RefreshScope
public PrincipalResolver x509SubjectAlternativeNameUPNPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SubjectAlternativeNameUPNPrincipalResolver r = new X509SubjectAlternativeNameUPNPrincipalResolver();
    r.setAttributeRepository(attributeRepository);
    r.setPrincipalAttributeName(x509.getPrincipal().getPrincipalAttribute());
    r.setReturnNullIfNoAttributes(x509.getPrincipal().isReturnNull());
    r.setPrincipalFactory(x509PrincipalFactory());
    return r;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:X509AuthenticationConfiguration.java

示例13: registerAuthenticationHandlerWithPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Override
public void registerAuthenticationHandlerWithPrincipalResolver(final AuthenticationHandler handler, final PrincipalResolver principalResolver) {
    if (principalResolver == null) {
        LOGGER.debug("Registering handler [{}] with no principal resolver into the execution plan", handler.getName());
    } else {
        LOGGER.debug("Registering handler [{}] principal resolver [{}] into the execution plan", handler.getName(), principalResolver);
    }
    this.authenticationHandlerPrincipalResolverMap.put(handler, principalResolver);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:DefaultAuthenticationEventExecutionPlan.java

示例14: personDirectoryPrincipalResolver

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Autowired
@RefreshScope
@Bean
@ConditionalOnMissingBean(name = "personDirectoryPrincipalResolver")
public PrincipalResolver personDirectoryPrincipalResolver(@Qualifier("attributeRepository") final IPersonAttributeDao attributeRepository,
                                                          @Qualifier("principalFactory") final PrincipalFactory principalFactory) {
    final PersonDirectoryPrincipalResolver bean = new PersonDirectoryPrincipalResolver();
    bean.setAttributeRepository(attributeRepository);
    bean.setPrincipalAttributeName(casProperties.getPersonDirectory().getPrincipalAttribute());
    bean.setReturnNullIfNoAttributes(casProperties.getPersonDirectory().isReturnNull());
    bean.setPrincipalFactory(principalFactory);
    return bean;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:CasCoreAuthenticationPrincipalConfiguration.java

示例15: verifyAuthenticateAnySuccess

import org.apereo.cas.authentication.principal.PrincipalResolver; //导入依赖的package包/类
@Test
public void verifyAuthenticateAnySuccess() throws Exception {
    final Map<AuthenticationHandler, PrincipalResolver> map = new HashMap<>();
    map.put(newMockHandler(true), null);
    map.put(newMockHandler(false), null);

    final PolicyBasedAuthenticationManager manager = new PolicyBasedAuthenticationManager(getAuthenticationExecutionPlan(map), mockServicesManager());
    final Authentication auth = manager.authenticate(transaction);
    assertEquals(1, auth.getSuccesses().size());
    assertEquals(2, auth.getCredentials().size());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:PolicyBasedAuthenticationManagerTests.java


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