package com.iformall.shiro;

import com.iformall.enums.EnumLoginType;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRetryLimitCredentialsMatcher extends HashedCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
        if(authcToken instanceof UseriFormallToken) {
            UseriFormallToken tk = (UseriFormallToken) authcToken;
            if(tk.getType().equals(EnumLoginType.NOPASSWD)){
                // 获取用户的输入的账号.
                String username = (String)tk.getPrincipal();
                return true;
            }
            boolean matches = super.doCredentialsMatch(authcToken, info);
            return matches;
        }
        boolean matches =super.doCredentialsMatch(authcToken, info);
        return matches;
    }
}
