Hi Julien,
I'm sorry the suggested solution didn't work out for you - the project mainly serves as a working example of what you need to add-on to Spring MVC to achieve the behavior you want. It uses custom request conditions (which is a feature of Spring MVC) and copies functionality from Spring Security's <authorize> jsp tag, making it pretty standard.
Anyway, I re-read your question and it seems that you only mentioned showing a login page to unauthenticated users. If this is all you need, you can add an intercept-url to block the "/" path and redirect users to the login page if they don't have sufficient privileges:
Code:
<http use-expressions="true">
<intercept-url pattern="/" access="isAuthenticated()" />
<form-login />
...
</http>
If you meant showing just content within a section of a page, and are using JSPs, you can use Spring Security's <authorize> tag:
Code:
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="isAnonymous()">
Login!
</sec:authorize>
<sec:authorize access="isAuthenticated()">
Hello!
</sec:authorize>
Unfortunately, if you want to return different page templates, there's no sleek out-of-the-box functionality. The most obvious way to do this is:
Code:
@RequestMapping("/")
public String homePage(Principal principal) {
if (principal is authenticated) {
return "dashboardPage";
}
return "promotionalPage";
}
Alternatively, you can implement your own filters/interceptors to check the authentication and forward the request to the appropriate request handler.
Thanks,
Andy