对acegi不是很熟悉但很感兴趣,请问如果通过了认证以后,相关的应用代码怎样获得当前主体的信息?比如登录的用户名什么的,因为有时候应用代码需要的到这些相关的信息来进行相关的处理。只看到说这些信息会存在ContextHolder里面,但具体怎么取出来使用呢?看了一下手册,是不是这样使用: Inside the SecurityContextHolder we store details of the principal currently interacting with the application. Acegi Security uses an Authentication object to represent this information. Whilst you won't normally need to create an Authentication object yourself, it is fairly common for users to query the Authentication object. You can use the following code block - from anywhere in your application - to do this:
[code]
Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (obj instanceof UserDetails) { String username = ((UserDetails)obj).getUsername(); } else { String username = obj.toString(); }
[/code]
分享到:
相关推荐
标签:acegi-security-tiger-1.0.0-RC2.jar.zip,acegi,security,tiger,1.0.0,RC2,jar.zip包下载,依赖包
Spring安全系统:Acegi Security--星月夜
acegi-security 1.0.2.jar
acegi-security-0.8.3驱动程序
标签:acegi-security-1.0.7.jar.zip,acegi,security,1.0.7,jar.zip包下载,依赖包
标签:acegi-security-0.8.1.jar.zip,acegi,security,0.8.1,jar.zip包下载,依赖包
标签:acegi-security-jetty-0.8.3.jar.zip,acegi,security,jetty,0.8.3,jar.zip包下载,依赖包
标签:acegi-security-1.0.4.jar.zip,acegi,security,1.0.4,jar.zip包下载,依赖包
标签:acegi-security-0.8.3.jar.zip,acegi,security,0.8.3,jar.zip包下载,依赖包
标签:acegi-security-resin-0.8.3.jar.zip,acegi,security,resin,0.8.3,jar.zip包下载,依赖包
标签:acegi-security-0.8.2.jar.zip,acegi,security,0.8.2,jar.zip包下载,依赖包
标签:acegi-security-0.6.1.jar.zip,acegi,security,0.6.1,jar.zip包下载,依赖包
Acegi是一个专门为SpringFramework提供安全机制的项目,全称为Acegi Security System for Spring.
acegi-security-1.0.4-src.zip acegi-security-1.0.4.jar的源码
标签:acegi-security-0.8.1.1.jar.zip,acegi,security,0.8.1.1,jar.zip包下载,依赖包
acegi-security-1.0.7.jar
acegi-security-1.0.0-RC2.jar
最近两星期在学习acegi,过程中感谢JavaEye,SpringSide和在网上提供acegi学习心得的网友们。 为了加深自己的认识,准备写下一些DEMO,希望可以给准备学习acegi的同学一些帮助。 作为安全服务离不开认证和授权这两个...
acegi-security-1.0.4.jar
acegi-security-1.0.7-sources jar 包