I'm using Spring MVC and Security to authenticate my web service.
I want the system to check that any newly authenticated users have accepted the EULA. If EULA check is good then let them continue on their merry ways.
If EULA check fails then have them stop by the "/eula" page until they accept.
I have the following class:
@Component
public class AssertEulaInterceptor extends HandlerInterceptorAdapter {
@Value("eulaCookieName")
private String cookieName;
@javax.annotation.Resource(name = "EULAResource")
private Resource eulaResource;
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
Cookie cookie = extractCookie(cookieName, request.getCookies());
if (assertEulaAccepted(request, response, handler, cookie)) {
response.sendRedirect("/services/eula");
}
}
}
and in my servlet-context.xml file:
...
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/static/j_spring_security_check*" />
<bean class="com.cafex.services.AssertEulaInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
...
But this doesn't do the check.
If I change the mvc:mapping to path="/login*" (which is the end-user touchpoint) then it gets into a redirect loop with the eula page (because the eula page is protected.)
Thanks.
Aucun commentaire:
Enregistrer un commentaire