纳金网

标题: spring acegi 官方例子1 [打印本页]

作者: Mr.cai    时间: 2011-7-29 17:53
标题: spring acegi 官方例子1










acegi安全是一个强大的,灵活的安全解决方案的企业软件,并特别着重于应用,利用spring。用acegi安全,为用户的应用与全面的认证,授权,例如基于职务的访问控制,通道安全和人类用户检测能力。(google 对acegid的翻译)

参考资料:http://www.tfo-eservices.eu/wb_tutorials/media/SpringAcegiTutorial/HTML/SpringAcegiTutorial-1_1-html.html

里面有一个例子:SpringAcegiTutorial,可以进行下载,并运行,做为一个实例,已经相当不错了。

讲述了admin ,user的登录问题。及权限控件,acegi 的配置。

这个例子是spring mvc + spring acegi 的例子,阅读前最好有spring mvc 的基础。这里只摘录简单的配置说明。
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><!-- ****** START ACEGI Security Configuration *******-->

<!-- ======================== FILTER CHAIN ======================= -->



<!-- if you wish to use channel security, add "channelProcessingFilter," in front

of "httpSessionContextIntegrationFilter" in the list below -->

<bean id="filterChainProxy"

class="org.acegisecurity.util.FilterChainProxy">

<property name="filterInvocationDefinitionSource">

<value>

CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON

PATTERN_TYPE_APACHE_ANT

/**=httpSessionContextIntegrationFilter,formAuthenticationProcessingFilter,exceptionTranslationFilter,filterSecurityInterceptor

</value>

</property>

</bean>



<!-- Start Security filter config -->

<bean id="exceptionTranslationFilter"

class="org.acegisecurity.ui.ExceptionTranslationFilter">

<property name="authenticationEntryPoint">

<ref bean="formLoginAuthenticationEntryPoint" />

</property>

</bean>



<!-- Define filter to handle BASIC authentication -->

<bean id="basicProcessingFilter"

class="org.acegisecurity.ui.basicauth.BasicProcessingFilter">

<property name="authenticationManager">

<ref bean="authenticationManager" />

</property>

<property name="authenticationEntryPoint">

<ref bean="authenticationEntryPoint" />

</property>

</bean>



<!-- Define realm for BASIC login-->

<bean id="authenticationEntryPoint"

class="org.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">

<property name="realmName">

<value>Spring Web Realm</value>

</property>

</bean>



<!-- Define filter to handle FORM authentication -->

<bean id="formAuthenticationProcessingFilter"

class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">

<property name="filterProcessesUrl">

<value>/j_acegi_security_check</value>

</property>

<property name="authenticationFailureUrl">

<value>/loginFailed.html</value>

</property>

<property name="defaultTargetUrl">

<value>/</value>

</property>

<property name="authenticationManager">

<ref bean="authenticationManager" />

</property>

</bean>



<!-- Define realm for FORM login-->

<bean id="formLoginAuthenticationEntryPoint"

class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">

<property name="loginFormUrl">

<value>/login.jsp</value>

</property>

<property name="forceHttps">

<value>false</value>

</property>

</bean>



<bean id="httpSessionContextIntegrationFilter"

class="org.acegisecurity.context.HttpSessionContextIntegrationFilter">

</bean>

<!-- End Security filter config -->



<!-- Start Security interceptor config -->

<!-- Define authentication manager, decision manager and secure URL patterns -->

<bean id="filterSecurityInterceptor"

class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">

<property name="authenticationManager">

<ref bean="authenticationManager" />

</property>

<property name="accessDecisionManager">

<ref bean="accessDecisionManager" />

</property>

<property name="objectDefinitionSource">

<value>

CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON

PATTERN_TYPE_APACHE_ANT

/secure/admin/*=ROLE_ADMIN

/secure/app/*=ROLE_USER

</value>

</property>

</bean>

<!-- End Security interceptor config -->












作者: 彬彬    时间: 2011-8-9 15:04

作者: 菜刀吻电线    时间: 2012-1-29 23:21
春节即将来到,我用祝福捻制成的绒线,烛光下为您织起一件红色的毛衣:前身是平安,后身是幸福,吉祥是厚厚的肩,如意戴在袖子里,领子蕴藏着体贴,口袋把快乐盛满,穿在身上让暖和包裹着您,让我的心陪伴您度过新年。

作者: 奇    时间: 2012-2-8 23:29
爱咋咋地!

作者: 晃晃    时间: 2012-2-13 23:23
无聊时可以刷屏幕 灌水 也可以试试 帖子的标题究竟可以写多长

作者: tc    时间: 2012-3-24 23:30
既来之,则看之!

作者: 菜刀吻电线    时间: 2012-4-27 23:27
不错 非常经典  实用

作者: C.R.CAN    时间: 2012-5-9 23:25
你们都躲开,我来顶

作者: 晃晃    时间: 2012-5-24 23:18
提醒猪猪,千万不能让你看见

作者: 奇    时间: 2012-9-3 01:18
先顶上去,偶要高亮加精鸟!

作者: 奇    时间: 2012-9-19 09:50
很有心,部分已收录自用,谢谢

作者: C.R.CAN    时间: 2012-10-13 23:23
好铁多多发,感激分享

作者: 晃晃    时间: 2012-12-4 23:21
已阵亡的 蝶 随 风 舞 说过  偶尔按一下 CTRL A 会发现 世界还有另一面

作者: 晃晃    时间: 2013-2-16 23:39
好`我顶``顶顶





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5