use of com.thoughtworks.go.server.security.tokens.PreAuthenticatedAuthenticationToken in project gocd by gocd.
the class PreAuthenticatedAuthenticationProvider method doAuthenticate.
private Authentication doAuthenticate(PreAuthenticatedAuthenticationToken preAuthToken) {
String pluginId = preAuthToken.getPluginId();
AuthenticationResponse response = null;
try {
response = authenticateUser(preAuthToken);
} catch (Exception e) {
handleUnSuccessfulAuthentication(preAuthToken);
}
if (!isAuthenticated(response)) {
handleUnSuccessfulAuthentication(preAuthToken);
}
validateUser(response.getUser());
assignRoles(pluginId, response.getUser().getUsername(), response.getRoles());
UserDetails userDetails = getUserDetails(response.getUser());
userService.addUserIfDoesNotExist(toDomainUser(response.getUser()));
PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(userDetails, preAuthToken.getCredentials(), pluginId, userDetails.getAuthorities());
result.setAuthenticated(true);
return result;
}
Aggregations