Java Code Examples for org.acegisecurity.Authentication#getCredentials()
The following examples show how to use
org.acegisecurity.Authentication#getCredentials() .
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: KualiCasAuthenticationProvider.java From rice with Educational Community License v2.0 | 6 votes |
/** * This overridden method is differs from the super method by * populating the user details by passing the full response * * @see org.acegisecurity.providers.cas.CasAuthenticationProvider#authenticateNow(Authentication authentication) */ private CasAuthenticationToken authenticateNow(Authentication authentication) throws AuthenticationException { // Validate KualiTicketResponse response = (KualiTicketResponse)this.getTicketValidator().confirmTicketValid(authentication.getCredentials().toString()); // Check proxy list is trusted this.getCasProxyDecider().confirmProxyListTrusted(response.getProxyList()); if (logger.isDebugEnabled()) { logger.debug("authenticationNOW:" + response); } // Lookup user details logger.debug("\n\npopulating authorities\n\n"); UserDetails userDetails = ((KualiCasAuthoritiesPopulator)this.getCasAuthoritiesPopulator()).getUserDetails(response); // Construct CasAuthenticationToken return new CasAuthenticationToken(this.getKey(), userDetails, authentication.getCredentials(), userDetails.getAuthorities(), userDetails, response.getProxyList(), response.getProxyGrantingTicketIou()); }
Example 2
Source File: KualiCasAuthenticationProvider.java From rice with Educational Community License v2.0 | 4 votes |
/** * This overridden method is copied from CAS verbatim. For some reason * {@link authenticateNow} would not override and the super method * would get called until did this method was also overridden. * * @see org.acegisecurity.providers.cas.CasAuthenticationProvider#authenticate(org.acegisecurity.Authentication) */ public Authentication authenticate(Authentication authentication) throws AuthenticationException { StatelessTicketCache statelessTicketCache = this.getStatelessTicketCache(); String key = this.getKey(); if (!supports(authentication.getClass())) { return null; } if (authentication instanceof UsernamePasswordAuthenticationToken && (!CasProcessingFilter.CAS_STATEFUL_IDENTIFIER.equals(authentication.getPrincipal().toString()) && !CasProcessingFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal().toString()))) { // UsernamePasswordAuthenticationToken not CAS related return null; } // If an existing CasAuthenticationToken, just check we created it if (authentication instanceof CasAuthenticationToken) { if (key.hashCode() == ((CasAuthenticationToken) authentication).getKeyHash()) { return authentication; } else { throw new BadCredentialsException(messages.getMessage("CasAuthenticationProvider.incorrectKey", "The presented CasAuthenticationToken does not contain the expected key")); } } // Ensure credentials are presented if ((authentication.getCredentials() == null) || "".equals(authentication.getCredentials())) { throw new BadCredentialsException(messages.getMessage("CasAuthenticationProvider.noServiceTicket", "Failed to provide a CAS service ticket to validate")); } boolean stateless = false; if (authentication instanceof UsernamePasswordAuthenticationToken && CasProcessingFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal())) { stateless = true; } CasAuthenticationToken result = null; if (stateless) { // Try to obtain from cache result = statelessTicketCache.getByTicketId(authentication.getCredentials().toString()); } if (result == null) { result = this.authenticateNow(authentication); result.setDetails(authentication.getDetails()); } if (stateless) { // Add to cache statelessTicketCache.putTicketInCache(result); } return result; }
Example 3
Source File: KualiTestAuthenticationProvider.java From rice with Educational Community License v2.0 | 4 votes |
private UsernamePasswordAuthenticationToken authenticateNow(Authentication authentication) throws AuthenticationException { return new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials(), new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_KUALI_USER")}); }