use of org.apache.nifi.registry.security.authentication.AuthenticationResponse in project nifi-registry by apache.
the class AccessResource method createAccessToken.
private String createAccessToken(IdentityProvider identityProvider, AuthenticationRequest authenticationRequest) throws InvalidCredentialsException, AdministrationException {
final AuthenticationResponse authenticationResponse;
try {
authenticationResponse = identityProvider.authenticate(authenticationRequest);
final String token = jwtService.generateSignedToken(authenticationResponse);
return token;
} catch (final IdentityAccessException | JwtException e) {
throw new AdministrationException(e.getMessage());
}
}
use of org.apache.nifi.registry.security.authentication.AuthenticationResponse in project nifi-registry by apache.
the class IdentityAuthenticationProvider method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
// Determine if this AuthenticationProvider's identityProvider should be able to support this AuthenticationRequest
boolean tokenOriginatedFromThisIdentityProvider = checkTokenOriginatedFromThisIdentityProvider(authentication);
if (!tokenOriginatedFromThisIdentityProvider) {
// cannot authenticate this token and another provider should be tried.
return null;
}
AuthenticationRequestToken authenticationRequestToken = ((AuthenticationRequestToken) authentication);
AuthenticationRequest authenticationRequest = authenticationRequestToken.getAuthenticationRequest();
try {
AuthenticationResponse authenticationResponse = identityProvider.authenticate(authenticationRequest);
if (authenticationResponse == null) {
return null;
}
return buildAuthenticatedToken(authenticationRequestToken, authenticationResponse);
} catch (InvalidCredentialsException e) {
throw new BadCredentialsException("Identity Provider authentication failed.", e);
}
}
Aggregations