2016-12-14 54 views
1

是否有可能创建日期依赖登录与Apache shiro?这意味着我可以指定特定用户只能在特定日期之间对应用程序进行身份验证。依赖日期的登录与shiro

回答

3

您可以扩展您正在使用的领域和覆盖的方法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; 
    } 
    } 
} 
+0

如果我靠IniRealm,有没有可能? –

+0

那么,只需将'extends JdbcReam'与'extends IniRealm' – JDC