2020-11-29 15:39:55 +08:00
..
2020-11-29 15:39:55 +08:00
2020-07-01 15:22:07 +08:00
2020-07-01 15:22:07 +08:00

Tigon Shiro

Usage

Define your AuthRealm

@Component
public class AuthRealmSupport implements AuthRealm<String> {

    @Autowired
    private TenantMapper tenantMapper;

    /**
     * {@inheritDoc}
     */
    @Override
    public Credential<String> credential(final String principal) {
        final Tenant tenant = tenantMapper.find(
            new Search(Tenant.ACCESS_KEY, principal));

        if (tenant != null) {
            if (!tenant.getActive()) {
                throw new LockedAccountException("Account locked");
            }
           final Credential<String> credential = new Credential<>(
                tenant.getAccessSecret(),
                principal);
            credential.setExtra(tenant);
            return credential;
        }

        return null;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean credentialMatch(final Object password, final Credential<String> credential) {
        return credential.getCredential().equals(password);
    }
}