package com.jiuzhou.common.interceptor;

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.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * @author YC
 */
public class ShiroRealm extends AuthorizingRealm {

	/*
	 * 登录信息和用户验证信息验证(non-Javadoc)
	 * @see org.apache.shiro.realm.AuthenticatingRealm#doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken)
	 */
	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

		String username = (String) token.getPrincipal(); // 得到用户名
		String password = new String((char[]) token.getCredentials()); // 得到密码

		if (null != username && null != password) {
			return new SimpleAuthenticationInfo(username, password, getName());
		} else {
			return null;
		}

	}

	/*
	 * 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用,负责在应用程序中决定用户的访问控制的方法(non-Javadoc)
	 * @see org.apache.shiro.realm.AuthorizingRealm#doGetAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection)
	 */
	@Override
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection pc) {

		System.out.println("========2");

		return null;
	}

}
最近下载更多
AAA孚盟软件售前刘美鲸  LV3 2021年10月20日
lironggang  LV38 2021年9月11日
houliukou  LV37 2020年2月14日
1234fdsafsafhgh56  LV5 2019年10月15日
z_lying  LV20 2019年5月31日
阿时23428  LV15 2019年5月21日
xwl123  LV12 2019年5月16日
一见倾心  LV9 2019年4月22日
709354102  LV10 2019年3月30日
suanpin  LV5 2019年1月18日
最近浏览更多
WBelong  LV7 2023年12月27日
pangzhihui  LV13 2023年12月11日
2036495585  LV9 2023年9月25日
飞呀飞呀飞不放  LV7 2023年8月9日
1379585889  LV11 2023年6月7日
uni-code_0123  LV1 2023年4月25日
泓鼎168  LV19 2023年4月11日
孟子大叔  LV7 2023年3月27日
upup996  LV6 2023年1月5日
小龙快飞  LV5 2022年12月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友