- 浏览: 4381392 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (163)
- 职场 && 心情 (22)
- Java/Basic (17)
- Java/Compression (7)
- Java/Security (20)
- Java/Maven (3)
- Java/Cache (11)
- Eclipse (4)
- Spring (19)
- ORM/Hibernate (2)
- ORM/iBatis (3)
- DB/NoSQL (11)
- DB/MySQL (7)
- DB/MS SQL Server (4)
- OS/Linux (11)
- OS/Mac (7)
- C/C++ (4)
- Server Architecture/Basic (13)
- Server Architecture/Distributed (17)
- Moblie/Andriod (2)
- WebService (3)
- Objective-C (1)
- Html (1)
- 设计模式 (1)
- Scala (0)
- Kafka (1)
最新评论
-
w47_csdn:
证书安装:在"浏览"选项中选择" ...
Java加密技术(九)——初探SSL -
w47_csdn:
spiritfrog 写道你好,我按照你的步骤,tomcat中 ...
Java加密技术(九)——初探SSL -
liuyachao111:
11楼说的对 用@ControllerAdvicepublic ...
Spring 注解学习手札(八)补遗——@ExceptionHandler -
irayslu:
作者你好, 我把你的源码放在jdk6, jdk7 中运行正常, ...
Java加密技术(五)——非对称加密算法的由来DH -
夏季浅忆-卖小子:
为什么不能解压rar格式的压缩包呢
Java压缩技术(三) ZIP解压缩——Java原生实现
项目需要 用acegi做为安全屏障,按acegi 1.0.1 官方自带的sample 拼了一个security-config.xml
但是 我不知道 登录后 当点击连接发送 xxx.do的请求后 我在Controller中如何得到用户的信息.例如ID,我该如何得到?
org.acegisecurity.userdetails.User中给的信息太少了
难不成 为了得到一个用户的ID我要由username再检索一遍数据库?
或者像众多兄弟一样除了接口几乎统统重写一遍?
希望是我文档没看够 大家指教~
另外saltSource我给了username提示找不到 User.username()方法 怪异
配置如下
但是 我不知道 登录后 当点击连接发送 xxx.do的请求后 我在Controller中如何得到用户的信息.例如ID,我该如何得到?
org.acegisecurity.userdetails.User中给的信息太少了
难不成 为了得到一个用户的ID我要由username再检索一遍数据库?
或者像众多兄弟一样除了接口几乎统统重写一遍?
希望是我文档没看够 大家指教~
另外saltSource我给了username提示找不到 User.username()方法 怪异
配置如下
<bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy"> <property name="filterInvocationDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor </value> </property> </bean> <!-- --> <bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter" /> <bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter"> <!-- URL redirected to after logout --> <constructor-arg value="/index.jsp" /> <constructor-arg> <list> <ref bean="rememberMeServices" /> <ref bean="securityContextLogoutHandler" /> </list> </constructor-arg> </bean> <bean id="securityContextLogoutHandler" class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" /> <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"> <property name="authenticationManager" ref="authenticationManager" /> <property name="authenticationFailureUrl" value="/acegilogin.jsp?login_error=1" /> <property name="defaultTargetUrl" value="/" /> <property name="filterProcessesUrl" value="/j_acegi_security_check" /> <property name="rememberMeServices" ref="rememberMeServices" /> </bean> <bean id="securityContextHolderAwareRequestFilter" class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter" /> <bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"> <property name="authenticationManager" ref="authenticationManager" /> <property name="rememberMeServices" ref="rememberMeServices" /> </bean> <bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"> <property name="key" value="changeThis" /> <property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS" /> </bean> <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter"> <property name="authenticationEntryPoint"> <ref bean="authenticationEntryPoint" /> </property> <property name="accessDeniedHandler"> <ref bean="accessDeniedHandler" /> </property> </bean> <bean id="authenticationEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"> <property name="loginFormUrl" value="/acegilogin.jsp" /> <property name="forceHttps" value="false" /> </bean> <bean id="accessDeniedHandler" class="org.acegisecurity.ui.AccessDeniedHandlerImpl"> <property name="errorPage" value="/accessDenied.jsp" /> </bean> <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"> <property name="authenticationManager" ref="authenticationManager" /> <property name="accessDecisionManager"> <ref bean="accessDecisionManager" /> </property> <property name="objectDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /secure/extreme/**=ROLE_SUPERVISOR /secure/**=IS_AUTHENTICATED_REMEMBERED /**=IS_AUTHENTICATED_ANONYMOUSLY </value> </property> </bean> <bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased"> <property name="allowIfAllAbstainDecisions" value="false" /> <property name="decisionVoters"> <list> <ref bean="roleVoter" /> <ref bean="authenticatedVoter" /> </list> </property> </bean> <bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter" /> <bean id="authenticatedVoter" class="org.acegisecurity.vote.AuthenticatedVoter" /> <bean id="rememberMeServices" class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"> <property name="userDetailsService" ref="userDetailsService" /> <property name="key" value="changeThis" /> </bean> <!-- 验证管理 --> <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager"> <property name="providers"> <list> <ref bean="daoAuthenticationProvider" /> <ref bean="anonymousAuthenticationProvider" /> <ref bean="rememberMeAuthenticationProvider" /> </list> </property> </bean> <bean id="anonymousAuthenticationProvider" class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"> <!-- 未明确 --> <property name="key" value="changeThis" /> </bean> <bean id="rememberMeAuthenticationProvider" class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"> <!-- 未明确 --> <property name="key" value="changeThis" /> </bean> <!-- dao层验证 暂时由数据库数据校验完成 可对数据库密码字段进行解密 可替换为在数据库层提取数据后 解析密码 然后核对 --> <bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"> <property name="userDetailsService" ref="userDetailsService" /> <property name="userCache"> <ref bean="userCache" /> </property> <!--property name="saltSource"> <ref bean="saltSource" /> </property> <property name="passwordEncoder"> <ref bean="passwordEncoder" /> </property--> </bean> <bean id="saltSource" class="org.acegisecurity.providers.dao.salt.ReflectionSaltSource"> <property name="userPropertyToUse"> <value>username</value> </property> </bean> <bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.Md5PasswordEncoder" /> <!-- 以下3项为用户信息缓存设置 减少数据库操作 --> <bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"> <property name="cache"> <ref bean="cache" /> </property> </bean> <bean id="cache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref bean="cacheManager" /> </property> <property name="cacheName" value="userCache" /> </bean> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation"> <value>/WEB-INF/ehcache.xml</value> </property> </bean> <!-- 可以替换为任何 UserDetailsService 接口的实现类 如 org.acegisecurity.userdetails.memory.InMemoryDaoImpl --> <bean id="userDetailsService" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <!-- This bean is optional; it isn't used by any other bean as it only listens and logs --> <bean id="loggerListener" class="org.acegisecurity.event.authentication.LoggerListener" /> </beans>
评论
5 楼
lendo.du
2007-09-05
1.你的用户信息Bean实现UserDetails接口。
2.你的角色对象Role实现GrantedAuthority接口。
这样你的SecurityContextHolder.getContext().getAuthentication().getPrincipal()方法返回的UserDetails对象就可以就可以转型为你自定义的用户信息Bean。
2.你的角色对象Role实现GrantedAuthority接口。
这样你的SecurityContextHolder.getContext().getAuthentication().getPrincipal()方法返回的UserDetails对象就可以就可以转型为你自定义的用户信息Bean。
4 楼
hendryxu
2006-11-24
支持一下
3 楼
snowolf
2006-09-22
这个还是自己解决了
晕 每次都是一样
通过auth就可以得到用户的基本信息
晕 每次都是一样
Authentication auth = SecurityContextHolder.getContext() .getAuthentication();
通过auth就可以得到用户的基本信息
2 楼
snowolf
2006-09-21
关键是
用户登录后 在什么地方保存了用户的信息
在controller中如何取到用户的信息
用户登录后 在什么地方保存了用户的信息
在controller中如何取到用户的信息
1 楼
IvanLi
2006-09-21
是否可以考虑自己声明一个UserInfo类,实现org.acegisecurity.userdetails.UserDetails这个接口即可?
发表评论
-
征服 Redis + Jedis + Spring (三)—— 列表操作
2013-03-06 16:16 83957一开始以为Spring下操 ... -
Memcached笔记——(四)应对高并发攻击
2012-09-13 09:48 28926近半个月过得很痛苦,主要是产品上线后,引来无数机器用户恶意 ... -
征服 Redis + Jedis + Spring (二)—— 哈希表操作(HMGET HMSET)
2012-08-29 18:29 82313不得不说,用哈希操作来存对象,有点自讨苦吃! 不过,既然 ... -
征服 Redis + Jedis + Spring (一)—— 配置&常规操作(GET SET DEL)
2012-08-29 16:30 157451有日子没写博客了,真的是忙得要疯掉。 完成项目基础架构搭建 ... -
Spring 注解学习手札(八)补遗——@ExceptionHandler
2012-08-17 18:35 84109Spring注解,改变了我的 ... -
Spring 注解学习手札(七) 补遗——@ResponseBody,@RequestBody,@PathVariable
2012-08-10 21:27 439639最近需要做些接口服务,服务协议定为JSON,为了整合在Spri ... -
征服 Kestrel + XMemcached + Spring TaskExecutor
2012-07-30 14:43 6204上一篇征服 Kestrel + XMemcached只是对Ke ... -
征服Spring AOP—— @AspectJ
2012-04-10 12:01 18653接N年前写的一篇Spring AOP相关的内容征服Spring ... -
Memcached笔记——(二)XMemcached&Spring集成
2012-04-01 09:55 42318今天研究Memcached的Java的Client,使用XMe ... -
Spring util
2011-02-24 12:02 01,<util:constant/> 取代了之前通 ... -
Spring HttpInvoke实现,以及效率提升!
2010-07-01 17:38 15017最近接手服务器总被人质疑效率问题,说到底是质疑Spring H ... -
Spring 注解学习手札(六) 测试
2010-02-05 16:28 53154既然系统基于注解自成一体,那么基于Spring的测试是否可以依 ... -
Spring 注解学习手札(五) 业务层事务处理
2010-02-04 16:11 25340控制器层、持久层都有 ... -
Spring 注解学习手札(四) 持久层浅析
2010-01-29 11:11 22575今天,我们玩玩数据库,搞搞持久层。不搞太复杂的东西,Sprin ... -
Spring 注解学习手札(三) 表单页面处理
2010-01-26 15:21 40477昨天小歇一天,看着两篇博客迅速飙升的点击率,十分欣慰。今天来研 ... -
Spring 注解学习手札(二) 控制层梳理
2010-01-24 15:53 36566昨天对Spring注解有了一 ... -
Spring 注解学习手札(一) 构建简单Web应用
2010-01-23 13:40 83384近来工作发生了一些变化,有必要学习一下Spring注解了! ... -
征服Spring AOP—— Schema
2008-09-03 17:41 6432自从开始使用Spring,就接触到AOP,但一直未能深入,沉淀 ... -
关于Spring中Commons Validator的使用说明
2008-09-01 09:57 8134关于Spring中Commons Validator的使用说明 ...
相关推荐
acegi,acegi,acegi
不错的ACEGI 教程
Acegi安全系统,是一个用于Spring Framework的安全框架,能够和目前流行的Web容器无缝集成。它使用了Spring的方式提供了安全和认证安全服务,包括使用Bean Context,拦截器和面向接口的编程方式。因此,Acegi安全...
Acegi文档 spring acegi 详细文档
Acegi安全系统,是一个用于Spring Framework的安全框架,能够和目前流行的Web容器无缝集成。它使用了Spring的方式提供了安全和认证安全服务,包括使用Bean Context,拦截器和面向接口的编程方式。因此,Acegi安全...
acegi 框架 介绍 spring 安全
Acegi能做什么 Acegi的体系结构 Acegi核心组件 典型的web认证过程 Acegi的登陆认证 Acegi对安全对象的访问控制 Filter 组件 Acegi的不足之处
NULL 博文链接:https://zw7534313.iteye.com/blog/2224254
acegi,spring的安全验证框架
关于Acegi的安全框架,里面有Acegi的实例,讲述得挺清楚的,
acegi-security 1.0.2.jar
acegi安全系统,是一个用于spring framework的安全框架,能够和目前流行的web容器无缝集成。它使用了spring的方式提供了安全和认证安全服务,包括使用bean context,拦截器和面向接口的编程方式。因此,acegi安全...
包含acegi-security-1.0.7.jar,acegi-security-1.0.7-sources.jar,acegi-security-cas-1.0.7.jar,acegi-security-cas-1.0.7-sources.jar,acegi-security-catalina-1.0.7.jar,acegi-security-catalina-1.0.7-...
Acegi使用.pdf
1、一个Acegi的例子,可以运行 2、一个很好的学Acegi的网址,0基础学习Acegi,强烈推荐 3、有什么问题可以发邮件heroshen@126.com讨论
spring acegi 使用工程demo
实战Acegi:使用Acegi作为基于Spring框架的WEB应
Acegi Security System for Spring
Acegi最新版v1.0.4,网络安全方面教程