使用 shiro 的日期相关登录

Date dependent login with shiro

是否可以使用 apache shiro 创建日期相关的登录?这意味着我将能够指定特定用户只能在特定日期之间对应用程序进行身份验证。

如果不满足日期条件,您可以扩展您正在使用的领域并覆盖方法doGetAuthenticationInfo(AuthenticationToken token)

public class DateRealm extends JdbcRealm {

  @Override
  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
      throws AuthenticationException {
    Date date = new Date();
    if ( /* Your dat condition here */ true) {
      return super.doGetAuthenticationInfo(token);
    } else {
      return null;
    }
  }
}