org.jasig.cas.authentication.principal.PrincipalResolver Java Examples
The following examples show how to use
org.jasig.cas.authentication.principal.PrincipalResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicyBasedAuthenticationManager.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
/** * Resolve principal. * * @param handlerName the handler name * @param resolver the resolver * @param credential the credential * @return the principal */ protected Principal resolvePrincipal( final String handlerName, final PrincipalResolver resolver, final Credential credential) { if (resolver.supports(credential)) { try { final Principal p = resolver.resolve(credential); 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.", handlerName, resolver, credential); } return null; }
Example #2
Source File: OpenIdSingleSignOnActionTests.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Before public void setUp() throws Exception { this.ticketRegistry = new DefaultTicketRegistry(); final OpenIdCredentialsAuthenticationHandler handler = new OpenIdCredentialsAuthenticationHandler(); handler.setTicketRegistry(this.ticketRegistry); this.authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( handler, new OpenIdPrincipalResolver())); final Map<String, UniqueTicketIdGenerator> generator = new HashMap<>(); generator.put(OpenIdService.class.getName(), new DefaultUniqueTicketIdGenerator()); impl = new CentralAuthenticationServiceImpl(this.ticketRegistry, null, this.authenticationManager, new DefaultUniqueTicketIdGenerator(), generator, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()), mock(LogoutManager.class)); this.action = new OpenIdSingleSignOnAction(); this.action.setCentralAuthenticationService(this.impl); this.action.setExtractor(new DefaultOpenIdUserNameExtractor()); this.action.afterPropertiesSet(); }
Example #3
Source File: PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Before public void setUp() throws Exception { this.action = new PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( new PrincipalBearingCredentialsAuthenticationHandler(), new PrincipalBearingPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); }
Example #4
Source File: PrincipalFromRequestUserPrincipalNonInteractiveCredentialsActionTests.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Before public void setUp() throws Exception { this.action = new PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( new PrincipalBearingCredentialsAuthenticationHandler(), new PrincipalBearingPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); }
Example #5
Source File: X509CertificateCredentialsNonInteractiveActionTests.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Before public void setUp() throws Exception { this.action = new X509CertificateCredentialsNonInteractiveAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final X509CredentialsAuthenticationHandler handler = new X509CredentialsAuthenticationHandler(); handler.setTrustedIssuerDnPattern("CN=\\w+,DC=jasig,DC=org"); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( handler, new X509SerialNumberPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); this.action.afterPropertiesSet(); }
Example #6
Source File: PolicyBasedAuthenticationManager.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
protected Principal resolvePrincipal( final String handlerName, final PrincipalResolver resolver, final Credential credential) { if (resolver.supports(credential)) { logger.info("{} resolved from {}", resolver, credential); try { final Principal p = resolver.resolve(credential); logger.debug("{} resolved {} from {}", resolver, p, credential); logger.info("{} 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.", handlerName, resolver, credential); logger.info( "{} is configured to use {} but it does not support {}, which suggests a configuration problem.", handlerName, resolver, credential); } return null; }
Example #7
Source File: OpenIdSingleSignOnActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { this.ticketRegistry = new DefaultTicketRegistry(); final OpenIdCredentialsAuthenticationHandler handler = new OpenIdCredentialsAuthenticationHandler(); handler.setTicketRegistry(this.ticketRegistry); this.authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( handler, new OpenIdPrincipalResolver())); final Map<String, UniqueTicketIdGenerator> generator = new HashMap<String, UniqueTicketIdGenerator>(); generator.put(OpenIdService.class.getName(), new DefaultUniqueTicketIdGenerator()); impl = new CentralAuthenticationServiceImpl(this.ticketRegistry, null, this.authenticationManager, new DefaultUniqueTicketIdGenerator(), generator, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()), mock(LogoutManager.class)); this.action = new OpenIdSingleSignOnAction(); this.action.setCentralAuthenticationService(this.impl); this.action.setExtractor(new DefaultOpenIdUserNameExtractor()); this.action.afterPropertiesSet(); }
Example #8
Source File: PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { this.action = new PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<String, UniqueTicketIdGenerator>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( new PrincipalBearingCredentialsAuthenticationHandler(), new PrincipalBearingPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); }
Example #9
Source File: PrincipalFromRequestUserPrincipalNonInteractiveCredentialsActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { this.action = new PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<String, UniqueTicketIdGenerator>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( new PrincipalBearingCredentialsAuthenticationHandler(), new PrincipalBearingPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); }
Example #10
Source File: X509CertificateCredentialsNonInteractiveActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { this.action = new X509CertificateCredentialsNonInteractiveAction(); final Map<String, UniqueTicketIdGenerator> idGenerators = new HashMap<String, UniqueTicketIdGenerator>(); idGenerators.put(SimpleWebApplicationServiceImpl.class.getName(), new DefaultUniqueTicketIdGenerator()); final X509CredentialsAuthenticationHandler handler = new X509CredentialsAuthenticationHandler(); handler.setTrustedIssuerDnPattern("CN=\\w+,DC=jasig,DC=org"); final AuthenticationManager authenticationManager = new PolicyBasedAuthenticationManager( Collections.<AuthenticationHandler, PrincipalResolver>singletonMap( handler, new X509SerialNumberPrincipalResolver())); final CentralAuthenticationServiceImpl centralAuthenticationService = new CentralAuthenticationServiceImpl( new DefaultTicketRegistry(), null, authenticationManager, new DefaultUniqueTicketIdGenerator(), idGenerators, new NeverExpiresExpirationPolicy(), new NeverExpiresExpirationPolicy(), mock(ServicesManager.class), mock(LogoutManager.class)); this.action.setCentralAuthenticationService(centralAuthenticationService); this.action.afterPropertiesSet(); }
Example #11
Source File: PolicyBasedAuthenticationManager.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
/** * Creates a new authentication manager with a list of authentication handlers that are attempted in the * listed order for supported credentials. This form may only be used by authentication handlers that * resolve principals during the authentication process. * * @param handlers Non-null list of authentication handlers containing at least one entry. */ public PolicyBasedAuthenticationManager(final List<AuthenticationHandler> handlers) { Assert.notEmpty(handlers, "At least one authentication handler is required"); this.handlerResolverMap = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>( handlers.size()); for (final AuthenticationHandler handler : handlers) { this.handlerResolverMap.put(handler, null); } }
Example #12
Source File: CasMultiFactorWebflowConfigurer.java From cas-mfa with Apache License 2.0 | 5 votes |
/** * Registers the default credentials-to-principal resolver for the second or later factors. Also attaches an * attribute repository to the resolver. */ protected void registerDefaultCredentialsToPrincipalResolver() { final List<PrincipalResolver> resolvers = this.context.getBean("mfaCredentialsToPrincipalResolvers", List.class); final PersonDirectoryPrincipalResolver defaultResolver = new PersonDirectoryPrincipalResolver(); final IPersonAttributeDao attributeRepository = this.context.getBean("attributeRepository", IPersonAttributeDao.class); final PrincipalFactory principalFactory = this.context.getBean("principalFactory", PrincipalFactory.class); defaultResolver.setAttributeRepository(attributeRepository); defaultResolver.setPrincipalFactory(principalFactory); resolvers.add(defaultResolver); }
Example #13
Source File: PolicyBasedAuthenticationManager.java From springboot-shiro-cas-mybatis with MIT License | 2 votes |
/** * Creates a new authentication manager with a map of authentication handlers to the principal resolvers that * should be used upon successful authentication if no principal is resolved by the authentication handler. If * the order of evaluation of authentication handlers is important, a map that preserves insertion order * (e.g. {@link LinkedHashMap}) should be used. * * @param map Non-null map of authentication handler to principal resolver containing at least one entry. */ public PolicyBasedAuthenticationManager(final Map<AuthenticationHandler, PrincipalResolver> map) { Assert.notEmpty(map, "At least one authentication handler is required"); this.handlerResolverMap = map; }
Example #14
Source File: PolicyBasedAuthenticationManager.java From cas4.0.x-server-wechat with Apache License 2.0 | 2 votes |
/** * Creates a new authentication manager with a map of authentication handlers to the principal resolvers that * should be used upon successful authentication if no principal is resolved by the authentication handler. If * the order of evaluation of authentication handlers is important, a map that preserves insertion order * (e.g. {@link LinkedHashMap}) should be used. * * @param map Non-null map of authentication handler to principal resolver containing at least one entry. */ public PolicyBasedAuthenticationManager(final Map<AuthenticationHandler, PrincipalResolver> map) { Assert.notEmpty(map, "At least one authentication handler is required"); this.handlerResolverMap = map; }