package com.nbclass.shiro.config;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;

public class MyHashedCredentialsMatcher extends HashedCredentialsMatcher {

	@Override
    public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
		MyUsernamePasswordToken tk = (MyUsernamePasswordToken) authcToken;
		// 如果是免密登录直接返回true
        if(tk.getType().equals(LoginType.NOPASSWD)){
        	return true;
        }
        // 不是免密登录，调用父类的方法
        return super.doCredentialsMatch(tk, info);
	}
}
