views:

22

answers:

1

I want to create a Wicket panel as a replacement for the default (and not so beautiful) Spring Security Login page. The form itself is not a big thing, because it's just HTML, but I also want to view Login errors.

I saw many JSP snippets containing ${SPRING_SECURITY_LAST_EXCEPTION} for viewing authentication errors, but how can I access this parameter from Wicket?

A: 

While I have never tried it, I think this should be the way:

EDIT: I fixed the bug now

    Request request = RequestCycle.get().getRequest();
    Object lastException = WebUtils.getSessionAttribute(
        ((ServletWebRequest) request).getHttpServletRequest(),
        WebAttributes.AUTHENTICATION_EXCEPTION
    );

See

seanizer
Thanks, but this ends up with a java.lang.ClassCastException: org.apache.wicket.protocol.http.servlet.ServletWebRequest cannot be cast to javax.servlet.http.HttpServletRequest.
Ethan Leroy
Ok, I just found a way to get the HttpServletRequest: HttpServletRequest req = ((ServletWebRequest) getRequest()).getHttpServletRequest(); So, now I have no Exceptions, but the getSessionAttribute method returns null, even if I provide the wrong credentials.
Ethan Leroy
OK, I fixed my bug now, but I'm amazed it doesn't work because that's pretty much what the spring guys are doing e.g. here: https://src.springframework.org/svn/spring-webflow/branches/spring-webflow-2.0-maintenance/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/login.xhtml
seanizer