this was my code for a simple form based authentication in a jsp file,Code:Object value = request.getSession().getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY); if (value != null && value instanceof BadCredentialsException) { BadCredentialsException badCredentialsException = (BadCredentialsException) value; out.print("Error logging in:" + badCredentialsException.getMessage()); } else { //Assuming that session conains the user header object... out.print("Login sucessful"); }
now I wanted to expand this code to detect open id based authentication success,
I found that the following code works:
basically I wanted a different message for a normal login and a different message for a openid loginCode:Object value = request.getSession().getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY); if (value != null && value instanceof BadCredentialsException) { BadCredentialsException badCredentialsException = (BadCredentialsException) value; out.print("Error logging in:" + badCredentialsException.getMessage()); } else if (value !=null && value instanceof OpenIDAuthenticationRequiredException) { SecurityContext ctx = SecurityContextHolder.getContext(); out.print("Login sucessful:" + ctx.getAuthentication().getName()); } else { out.print("Login sucessful"); }
so, why does spring place an OpenIDAuthenticationRequiredException in my code @ a valid openid login?



