package com.simuwang.shiro.core;

import jakarta.annotation.PostConstruct;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * @author wangzaijun
 * @date 2024/9/6 17:16
 * @description 自定义的shiro realm
 */
public abstract class ShiroDbRealm extends AuthorizingRealm {
    /**
     * principals 令牌
     *
     * @param principalCollection 用户信息
     * @return /
     */
    @Override
    public abstract AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection);

    /**
     * authToken 对象
     *
     * @param authenticationToken 认证后的token
     * @return /
     * @throws AuthenticationException /
     */
    @Override
    public abstract AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException;

    /**
     * 密码匹配器
     */
    @PostConstruct
    public abstract void initCredentialsMatcher();
}
