Java tutorial
/* * Copyright (c) 2010 iceScrum Technologies. * * This file is part of iceScrum. * * iceScrum is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License. * * iceScrum is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with iceScrum. If not, see <http://www.gnu.org/licenses/>. * * Authors: * * Stphane Maldini (stephane.maldini@icescrum.com) */ package org.icescrum.core.security; import org.icescrum.core.services.SecurityService; import org.springframework.expression.EvaluationContext; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.security.access.hierarchicalroles.RoleHierarchy; import org.springframework.security.authentication.AuthenticationTrustResolver; import org.springframework.security.authentication.AuthenticationTrustResolverImpl; import org.springframework.security.core.Authentication; import org.springframework.security.web.FilterInvocation; import org.springframework.security.web.access.expression.WebSecurityExpressionHandler; public class WebScrumExpressionHandler implements WebSecurityExpressionHandler { private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); private ExpressionParser expressionParser = new SpelExpressionParser(); private RoleHierarchy roleHierarchy; private org.icescrum.core.services.SecurityService securityService; public void setSecurityService(SecurityService securityService) { this.securityService = securityService; } public ExpressionParser getExpressionParser() { return expressionParser; } public EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi) { StandardEvaluationContext ctx = new StandardEvaluationContext(); WebScrumExpressionRoot root = new WebScrumExpressionRoot(authentication, fi); root.setTrustResolver(trustResolver); root.setRoleHierarchy(roleHierarchy); root.setSecurityService(securityService); ctx.setRootObject(root); return ctx; } public void setRoleHierarchy(RoleHierarchy roleHierarchy) { this.roleHierarchy = roleHierarchy; } }