/** * Wrap credentials into an authentication transaction, as a factory method, * and return the final result. * * @param credentials the credentials * @return the authentication transaction */ public static AuthenticationTransaction wrap(final Credential... credentials) { return new AuthenticationTransaction(sanitizeCredentials(credentials)); }
@Override public AuthenticationTransactionManager handle(final AuthenticationTransaction authenticationTransaction, final AuthenticationContextBuilder authenticationContext) throws AuthenticationException { if (!authenticationTransaction.getCredentials().isEmpty()) { final Authentication authentication = this.authenticationManager.authenticate(authenticationTransaction); LOGGER.debug("Successful authentication; Collecting authentication result [{}]", authentication); authenticationContext.collect(authentication); } LOGGER.debug("Transaction ignored since there are no credentials to authenticate"); return this; }
this.authenticationSystemSupport.getPrincipalElectionStrategy()); final AuthenticationTransaction transaction = AuthenticationTransaction.wrap(credential); this.authenticationSystemSupport.getAuthenticationTransactionManager().handle(transaction, builder); final AuthenticationContext authenticationContext = builder.build();
@Override protected Event doExecute(final RequestContext context) throws Exception { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); final String authTokenValue = request.getParameter(TokenConstants.PARAMETER_NAME_TOKEN); final Service service = WebUtils.getService(context); if (StringUtils.isNotBlank(authTokenValue) && service != null) { try { final Credential credential = new TokenCredential(authTokenValue, service); LOGGER.debug("Received token authentication request {} ", credential); final AuthenticationContextBuilder builder = new DefaultAuthenticationContextBuilder( this.authenticationSystemSupport.getPrincipalElectionStrategy()); final AuthenticationTransaction transaction = AuthenticationTransaction.wrap(credential); this.authenticationSystemSupport.getAuthenticationTransactionManager().handle(transaction, builder); final AuthenticationContext authenticationContext = builder.build(service); final TicketGrantingTicket tgt = this.centralAuthenticationService.createTicketGrantingTicket(authenticationContext); WebUtils.putTicketGrantingTicketInScopes(context, tgt); return success(); } catch (final Exception e) { LOGGER.warn(e.getMessage(), e); } } return error(); }
this.authenticationSystemSupport.getPrincipalElectionStrategy()); final AuthenticationTransaction transaction = AuthenticationTransaction.wrap(credential); this.authenticationSystemSupport.getAuthenticationTransactionManager() .handle(transaction, builder);
@Override @Audit( action="AUTHENTICATION", actionResolverName="AUTHENTICATION_RESOLVER", resourceResolverName="AUTHENTICATION_RESOURCE_RESOLVER") @Timed(name="AUTHENTICATE_TIMED") @Metered(name="AUTHENTICATE_METER") @Counted(name="AUTHENTICATE_COUNT", monotonic=true) public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException { final AuthenticationBuilder builder = authenticateInternal(transaction.getCredentials()); final Authentication authentication = builder.build(); final Principal principal = authentication.getPrincipal(); if (principal instanceof NullPrincipal) { throw new UnresolvedPrincipalException(authentication); } addAuthenticationMethodAttribute(builder, authentication); logger.info("Authenticated {} with credentials {}.", principal, transaction.getCredentials()); logger.debug("Attribute map for {}: {}", principal.getId(), principal.getAttributes()); populateAuthenticationMetadataAttributes(builder, transaction.getCredentials()); return builder.build(); }
final AuthenticationContextBuilder builder = new DefaultAuthenticationContextBuilder( this.authenticationSystemSupport.getPrincipalElectionStrategy()); final AuthenticationTransaction transaction = AuthenticationTransaction.wrap(credential); this.authenticationSystemSupport.getPrincipalElectionStrategy()); final AuthenticationTransaction transaction = AuthenticationTransaction.wrap(credential); this.authenticationSystemSupport.getAuthenticationTransactionManager().handle(transaction, builder); final AuthenticationContext authenticationContext = builder.build(service);