SubjectAuthenticationResult subjectAuthenticationResult;
if (exception != null) {
subjectAuthenticationResult = new SubjectAuthenticationResult(
new AuthenticationResult(AuthenticationStatus.ERROR, exception));
}
else if (successfulAuth)
{
subjectAuthenticationResult = new SubjectAuthenticationResult(
new AuthenticationResult(mock(Principal.class)), _loginSubject);
}
else
{
subjectAuthenticationResult = new SubjectAuthenticationResult(new AuthenticationResult(AuthenticationStatus.CONTINUE));
}
when(subjectCreator.authenticate(anyString(), anyString())).thenReturn(subjectAuthenticationResult);
return subjectCreator;