return null;
}
};
}
final UserNameCredential realCredential = UserNameCredential.class.cast( credential );
if ( !authenticationSource.authenticate( realCredential, securityContext ) ) {
return new AuthenticationResult() {
@Override
public List<String> getMessages() {
return new ArrayList<String>( 1 ) {{
add( "Invalid credentials." );
}};
}
@Override
public AuthenticationStatus getStatus() {
return AuthenticationStatus.FAILED;
}
@Override
public Principal getPrincipal() {
return null;
}
};
}
return new AuthenticationResult() {
@Override
public List<String> getMessages() {
return emptyList();
}
@Override
public AuthenticationStatus getStatus() {
return AuthenticationStatus.SUCCESS;
}
@Override
public Principal getPrincipal() {
return new PrincipalImpl( realCredential.getUserName() );
}
};
}