Shiro无密码登录
2015-12-07 11:59
337 查看
在某些应用场景下我们或许需要直接登录,而不需要用户输入密码,例如用户用手机直接登录的场景。
在Shiro中我们通过在线程变量中绑定一个已通过验证的Subject对象即可实现。
PrincipalCollection principals = new SimplePrincipalCollection(
user.getId(), "MobileRealm");
Builder builder = new WebSubject.Builder(
ServletActionContext.getRequest(),
ServletActionContext.getResponse());
builder.principals(principals);
builder.authenticated(true);
WebSubject subject = builder.buildWebSubject();
ThreadContext.bind(subject);
在Shiro中我们通过在线程变量中绑定一个已通过验证的Subject对象即可实现。
PrincipalCollection principals = new SimplePrincipalCollection(
user.getId(), "MobileRealm");
Builder builder = new WebSubject.Builder(
ServletActionContext.getRequest(),
ServletActionContext.getResponse());
builder.principals(principals);
builder.authenticated(true);
WebSubject subject = builder.buildWebSubject();
ThreadContext.bind(subject);
相关文章推荐
- Apache Shiro 使用手册(一) Shiro架构介绍
- Apache Shiro 使用手册(二) Shiro 认证
- Apache Shiro 使用手册(五) Shiro 配置说明
- Apache Shiro 使用手册(四) Realm 实现
- 让Apache Shiro保护你的应用
- Linux下实现SSH免密码登录和实现秘钥的管理、分发、部署SHELL脚本分享
- 基于Spring框架的Shiro配置方法
- 使用Shiro实现登录成功后跳转到之前的页面
- Spring+mybatis+shiro+freemarker+ehcache+ldap+mongo
- 第四章 INI配置
- 第五章 编码/加密
- 第六章 Realm及相关对象
- Shiro预览
- JFinal-Beetl-Shiro(JdbcRealm)-例子
- springrain技术详解
- S2SH整合Shiro之:SessionContext must be an HTTP compatible implementation
- S2SH整合Shiro之:java.lang.NoSuchMethodException: com.sun.proxy.$Proxy25
- 让Apache Shiro保护你的应用
- 第二章 身份验证——《跟我学Shiro》
- 第三章 授权——《跟我学Shiro》