in redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java [73:124]
public AuthenticationResult authenticate( AuthenticationDataSource source )
throws AccountLockedException, AuthenticationException, MustChangePasswordException
{
TokenBasedAuthenticationDataSource dataSource = (TokenBasedAuthenticationDataSource) source;
String key = dataSource.getToken();
try
{
AuthenticationKey authKey = keystore.findKey( key );
// if we find a key (exception was probably thrown if not) then we should be authentic
if ( authKey != null )
{
User user = userManager.findUser( dataSource.getUsername() );
if ( user.isLocked() )
{
throw new AccountLockedException( "Account " + source.getUsername() + " is locked.", user );
}
if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
{
throw new MustChangePasswordException( "Password expired.", user );
}
return new AuthenticationResult( true, dataSource.getUsername(), null );
}
else
{
return new AuthenticationResult( false, dataSource.getUsername(),
new AuthenticationException( "unable to find key" ) );
}
}
catch ( KeyNotFoundException ne )
{
return new AuthenticationResult( false, null, ne );
}
catch ( KeyManagerException ke )
{
throw new AuthenticationException( "underlaying keymanager issue", ke );
}
catch ( UserNotFoundException e )
{
log.warn( "Login for user {} failed. user not found.", source.getUsername() );
return new AuthenticationResult( false, null, e );
}
catch ( UserManagerException e )
{
log.warn( "Login fail for user {} failed. message: {}", source.getUsername(), e.getMessage() );
return new AuthenticationResult( false, null, e );
}
}