pattern = hasCollege('college1',college2')
のようなインターセプトURLパターンを指定したいと思います。そのために、私は、次のアプローチを考えています:スプリングセキュリティ - カスタムSPELアクセス式を作成します。私のアプローチは正しいのですか?
A)
<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カスタム式ハンドラを使用するようにWebExpressionVoter
を設定)EEWebSecurityExpressionHandler
がDefaultWebSecurityExpressionHandler
の方法でWebSecurityExpressionHandler
を実装し、カスタムを設定するcreateEvaluationContext
を使用してくださいルートオブジェクト。
@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