I needed to protect access to web resources (project information in this case) to only projects a user was assigned to. I created a voter that looks something like:
I wired this in front of the role based voter in a UnanimousBased approach. This works great but I was wondering if ACL's would be better. FWIW, I used the above to replace a method intercept based approach I used earlier.Code:public int vote(Authentication authentication, Object object, ConfigAttributeDefinition config) { if ((object == null) || !this.supports(object.getClass())) { throw new IllegalArgumentException("Does not support the presented Object type"); } FilterInvocation invocation = (FilterInvocation) object; HttpServletRequest request = invocation.getHttpRequest(); String username = authentication.getPrincipal().toString(); int result = ACCESS_ABSTAIN; Iterator iter = config.getConfigAttributes(); while (iter.hasNext()) { ConfigAttribute attribute = (ConfigAttribute) iter.next(); if (this.supports(attribute)) { String projectId = null; projectId = request.getParameter(PROJECT_ID_PARAM); if (projectId != null) { result = ACCESS_DENIED; if (getAdminService().isProjectAssigned(username, projectId)) { return ACCESS_GRANTED; } } } } return result; }


