资源简介
Shiro入门实例 Shiro入门教程 Shiro框架学习demo http://www.xttblog.com/?p=669 权限管理教程。Shiro是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理等功能。
Shiro可以在任何环境下运行,小到最简单的命令行应用,大到大型的企业应用以及集群应用。但是我们准备在快速指南中使用最最简单的main方法的方式,让你对Shiro的API有个感官的认识。

代码片段和文件信息
package com.taoge.shiro.authenticator.strategy;
import java.util.Collection;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.pam.AbstractAuthenticationStrategy;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.util.CollectionUtils;
/**
* Shiro框架学习demo
* 业余草:www.xttblog.com
* QQ1群:135430763(已满)
* QQ2群:454796847
* @author 涛哥
* @date 2016年8月8日14:46:10
*/
public class AtLeastTwoAuthenticatorStrategy extends AbstractAuthenticationStrategy {
@Override
public AuthenticationInfo beforeAllAttempts(Collection extends Realm> realms AuthenticationToken token) throws AuthenticationException {
return new SimpleAuthenticationInfo();//返回一个权限的认证信息
}
@Override
public AuthenticationInfo beforeAttempt(Realm realm AuthenticationToken token AuthenticationInfo aggregate) throws AuthenticationException {
return aggregate;//返回之前合并的
}
@Override
public AuthenticationInfo afterAttempt(Realm realm AuthenticationToken token AuthenticationInfo singleRealmInfo AuthenticationInfo aggregateInfo Throwable t) throws AuthenticationException {
AuthenticationInfo info;
if (singleRealmInfo == null) {
info = aggregateInfo;
} else {
if (aggregateInfo == null) {
info = singleRealmInfo;
} else {
info = merge(singleRealmInfo aggregateInfo);
}
}
return info;
}
@Override
public AuthenticationInfo afterAllAttempts(AuthenticationToken token AuthenticationInfo aggregate) throws AuthenticationException {
if (aggregate == null || CollectionUtils.isEmpty(aggregate.getPrincipals()) || aggregate.getPrincipals().getRealmNames().size() < 2) {
throw new AuthenticationException(“Authentication token of type [“ + token.getClass() + “] “ +
“could not be authenticated by any configured realms. Please ensure that at least two realm can “ +
“authenticate these tokens.“);
}
return aggregate;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-08-08 14:41 shiro-demo1\
文件 1431 2016-08-08 14:13 shiro-demo1\.classpath
文件 563 2016-08-08 14:13 shiro-demo1\.project
目录 0 2016-08-08 14:13 shiro-demo1\.settings\
文件 57 2016-08-08 14:13 shiro-demo1\.settings\org.eclipse.core.resources.prefs
文件 243 2016-08-08 14:13 shiro-demo1\.settings\org.eclipse.jdt.core.prefs
文件 90 2016-08-08 14:12 shiro-demo1\.settings\org.eclipse.m2e.core.prefs
目录 0 2016-08-08 14:41 shiro-demo1\doc\
目录 0 2016-08-08 14:43 shiro-demo1\doc\sql\
文件 1980 2016-08-08 14:43 shiro-demo1\doc\sql\shiro.sql
文件 1331 2016-08-08 17:14 shiro-demo1\pom.xm
目录 0 2016-08-08 14:12 shiro-demo1\src\
目录 0 2016-08-08 14:12 shiro-demo1\src\main\
目录 0 2016-08-08 14:39 shiro-demo1\src\main\java\
目录 0 2016-08-08 17:14 shiro-demo1\src\main\java\com\
目录 0 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\
目录 0 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\shiro\
目录 0 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\shiro\authenticator\
目录 0 2016-08-08 14:39 shiro-demo1\src\main\java\com\taoge\shiro\authenticator\strategy\
文件 2333 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\shiro\authenticator\strategy\AtLeastTwoAuthenticatorStrategy.java
文件 2317 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\shiro\authenticator\strategy\OnlyOneAuthenticatorStrategy.java
目录 0 2016-08-08 14:52 shiro-demo1\src\main\java\com\taoge\shiro\realm\
文件 2133 2016-08-08 17:14 shiro-demo1\src\main\java\com\taoge\shiro\realm\MyRealm.java
目录 0 2016-08-08 15:23 shiro-demo1\src\main\resources\
文件 447 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-authenticator-all-fail.ini
文件 447 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-authenticator-all-success.ini
文件 500 2016-08-08 15:26 shiro-demo1\src\main\resources\shiro-authenticator-atLeastOne-success.ini
文件 472 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-authenticator-atLeastTwo-success.ini
文件 449 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-authenticator-first-success.ini
文件 523 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-authenticator-onlyone-success.ini
文件 319 2016-08-08 15:23 shiro-demo1\src\main\resources\shiro-jdbc-realm.ini
............此处省略53个文件信息
相关资源
- Java微信小程序商城
- Realm数据库操作,版本更新数据迁移及
- shiro-root-1.3.2-source-release包含shirojar包
- Java安全框架Shiro电子书
- 权限管理系统 shiro + ssm实现
- springboot+memcached+mybatis+shiro+webservice聚
- 毕业设计ssm点餐项目
- Java SSM、 shiro开发用户登录权限认证的
- 单点登录sso-shiro-cas-maven
- 跟我学Shiro教程及其课程分章节源码
- Shiro教程:跟我学Shiro
- shiro的中文基础教程(92页)
- ssm+shiro基于资源的权限控制框架包含
- Springboot+Mybatis-plus+ SpringMvc+Shiro+Redis企
- erp完整源码-ssm+easyUI+mysql+maven+shiro
- erp源码-ssm+easyUI+mysql+maven+shiro
- 千锋Java教程:Shiro框架从入门到实战
- Shiro安装需要jar包
- shiro-all-1.4.0.jar
- springboot+shiro实现后端请求权限控制
- adnroid开发框架rxjava+dagger2+retrofit2okh
- SpringBoot与Shiro整合-权限管理实战视频
- java ssm权限管理系统 慕课实战
- 尚硅谷shiro视频
- shiro框架jar包+全
- shiro 1.4.0所有jar包全
- 用户权限springmvc+shiro(数据库需自行
- jsets-shiro-spring-boot-starter
- SpringMVC整合shiro、mybatis、redis的
- java通用后台框架源码(1.+MyBatis3.4.6、
评论
共有 条评论