Sparkle’s Workshop

Archive for April 19th, 2005

annotation for acegi

Posted on April 19, 2005 - Filed Under Java

UPDATE: The new version of acegi has itself’s annotation implement. So you don’t need this any more.
annotation is so good that i can’t wait to use it in acegi
code sample

import java.util.List;
import org.gotblog.common.acegi.SecurityConfig;
import org.springframework.transaction.annotation.Transactional;
public interface BookManager {
@Transactional
@SecurityConfig( { "ROLE_USER", "ROLE_ANONYMOUS" [...]

Read More..>>

acegi基本使用一

Posted on April 19, 2005 - Filed Under Uncategorized

acegi真的超级难用,花了大量时间才调试出来
我使用的版本是acegi-security-0.8.1
目标是使用acegi通过spring aop直接对service bean的每一个method做权限
在web.xml加入

Acegi Filter Chain Proxy
net.sf.acegisecurity.util.FilterToBeanProxy

targetClass

net.sf.acegisecurity.util.FilterChainProxy

Acegi Filter Chain Proxy
/*

FilterToBeanProxy是从servletfilter跳至spring bean的媒介
实际上,targetClass所接受的必须是spring bean定义了的类的类名
而且,这个类也是实现servletfilter接口的(以下称这个类为acegi filter)
FilterToBeanProxy是整个acegi的总入口,把servletfilter跟spring bean穿起来了
实现得非常好,建议参看源代码,代码也非常精练
targetClass只接受一个acegi filter,入口参数是类名
这个类名必须至少在spring定义一个bean
acegi里面有若干不同特性的预定acegi filter供选择使用
往往我们不仅仅需要一个acegi filter,所以这里我们借助FilterChainProxy
FilterChainProxy主要是通过正则表达式将特定的URI提交给若干acegi filter做处理
这样,acegi在web.xml的配置算完了
当然,acegi还有提供若干其他servletfilter
不过这次用不上

Read More..>>