/** * Helper method to construct a handler result * on successful authentication events. * * @param credential the credential on which the authentication was successfully performed. * Note that this credential instance may be different from what was originally provided * as transformation of the username may have occurred, if one is in fact defined. * @param principal the resolved principal * @param warnings the warnings * @return the constructed handler result */ protected final HandlerResult createHandlerResult(final Credential credential, final Principal principal, final List<MessageDescriptor> warnings) { return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential), principal, warnings); } }
@Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (credential instanceof CredentialMetaData) { md = (CredentialMetaData) credential; } else { md = new BasicCredentialMetaData(credential); } return new DefaultHandlerResult(this, md); } else { throw new FailedLoginException( String.format("%s failed to authenticate %s", this.getName(), credential)); } } catch (final org.jasig.cas.authentication.handler.AuthenticationException e) { throw new GeneralSecurityException( String.format("%s failed to authenticate %s", this.getName(), credential), e); } }
@Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException { final OpenIdCredential c = (OpenIdCredential) credential; final TicketGrantingTicket t = this.ticketRegistry.getTicket(c.getTicketGrantingTicketId(), TicketGrantingTicket.class); if (t == null || t.isExpired()) { throw new FailedLoginException("TGT is null or expired."); } final Principal principal = t.getAuthentication().getPrincipal(); if (!principal.getId().equals(c.getUsername())) { throw new FailedLoginException("Principal ID mismatch"); } return new DefaultHandlerResult(this, new BasicCredentialMetaData(c), principal); }
throw new FailedLoginException("Principal is null, the processing of the SPNEGO Token failed"); return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential), spnegoCredential.getPrincipal());
/** * Build the handler result. * * @param credentials the provided credentials * @param profile the retrieved user profile * @return the built handler result * @throws GeneralSecurityException On authentication failure. * @throws PreventedException On the indeterminate case when authentication is prevented. */ protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile) throws GeneralSecurityException, PreventedException { if (profile != null) { final String id; if (typedIdUsed) { id = profile.getTypedId(); } else { id = profile.getId(); } if (StringUtils.isNotBlank(id)) { credentials.setUserProfile(profile); credentials.setTypedIdUsed(typedIdUsed); return new DefaultHandlerResult( this, new BasicCredentialMetaData(credentials), this.principalFactory.createPrincipal(id, profile.getAttributes())); } throw new FailedLoginException("No identifier found for this user profile: " + profile); } throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials); }
builder.addCredential(new BasicCredentialMetaData(c));
throw new FailedLoginException(); return new DefaultHandlerResult(this, new BasicCredentialMetaData(ntlmCredential), ntlmCredential.getPrincipal());