pattern = hasCollege('college1',college2')
과 같은 요격 패턴을 지정하고 싶습니다. 이를 위해, 나는 다음과 같은 접근 방식을 생각하고 :봄 보안 - 맞춤 SPEL 액세스 표현을 작성합니다. 내 접근 방식이 맞습니까?
A) DefaultWebSecurityExpressionHandler
의 방식으로 WebSecurityExpressionHandler
을 구현 EEWebSecurityExpressionHandler
확인) 사용자 정의 표현 핸들러에게
<beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<beans:property name="decisionVoters">
<beans:list>
<beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter">
<beans:property name="expressionHandler" ref="myWebSecurityExpressionHandler"/>
</beans:bean>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="myWebSecurityExpressionHandler" class="com.daud.security.EEWebSecurityExpressionHandler"/>
B를 사용하고 사용자 정의를 설정하는 createEvaluationContext
를 사용하는 WebExpressionVoter
구성 루트 객체.
@Override
public EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi) {
StandardEvaluationContext ctx = new StandardEvaluationContext();
SecurityExpressionRoot root = new MyWebSecurityExpressionRoot(authentication, fi);
root.setTrustResolver(trustResolver);
root.setRoleHierarchy(roleHierarchy);
ctx.setRootObject(root);
return ctx;
}
C) MyWebSecurityExpressionRoot
가 WebSecurityExpressionRoot
를 확장하고 새로운 SPEL 표현에 해당하는 새로운 방법을 선언합니다 :
public final boolean hasCollege(String... colleges){
// logic goes here
}
이 문제를 접근하는 올바른 방법인가를?
[여기] (http://forum.springsource.org/showthread.php?75331-Configuration-of-Spring-Security-3-0M1-Expression-Handler-bug&p=271798#post271798) 및 [여기 ] (http://stackoverflow.com/questions/6632982/how-to-create-custom-methods-for-use-in-spring-security-expression-language-anno) – nobeh