net.sourceforge.web.security.SecurityRealm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jweb-common Show documentation
Show all versions of jweb-common Show documentation
本项目主要弥补在使用mybatis3+springmvc+jquery easyui快速搭建web应用系统是遇到的框架不足.
主要工作包括:
1,扩展了ApplicationContextAware,通过单例注入spring容器,提供spring容器外的bean获取方法
2,扩展了apache shiro框架,统一了安全结构
3,扩展了mybatis3拦截器,在两个拦截器中自动完成分页注入,实现内存分页。
4,分页设计数据库方言
5,提供了一个easyuigrid的模型
6,提供了java泛型的jstl
7, xml工具包等一些小工具
The newest version!
package net.sourceforge.web.security;
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.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
/**
* 用户身份验证,授权 Realm 组件
*
* @deprecated
* @author [email protected]
**/
public class SecurityRealm extends AuthorizingRealm {
/**
* 权限检查
*/
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
return authorizationInfo;
}
/**
* 登录验证
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
String username = String.valueOf(token.getPrincipal());
String password = new String((char[]) token.getCredentials());
// 通过数据库进行验证
// final User authentication = userService.authentication(new User(username,
// password));
// if (authentication == null) {
// throw new AuthenticationException("用户名或密码错误.");
// }
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(username, password, getName());
return authenticationInfo;
}
}