maxkey-core/src/main/java/org/maxkey/persistence/db/PasswordPolicyValidator.java
/**
    * dynamic passwordPolicy Valid for user login.
    * @param userInfo
    * @return boolean
    */
dynamic passwordPolicy Valid for user login.
@param userInfo
@return boolean
dynamic passwordPolicy Valid for user login . @param userInfo @return boolean
public boolean passwordPolicyValid(UserInfo userInfo) {
       getPasswordPolicy();
       DateTime currentdateTime = new DateTime();
        /*
         * check login attempts fail times
         */
        if (userInfo.getBadPasswordCount() >= passwordPolicy.getAttempts()) {
            _logger.debug("login Attempts is " + userInfo.getBadPasswordCount());
            String badPasswordTimeString = userInfo.getBadPasswordTime().substring(0, 19);
            _logger.trace("bad Password Time " + badPasswordTimeString);
            DateTime badPasswordTime = DateTime.parse(badPasswordTimeString,
                    DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
            Duration duration = new Duration(badPasswordTime, currentdateTime);
            int intDuration = Integer.parseInt(duration.getStandardHours() + "");
            _logger.debug("bad Password duration {} , " + 
                          "password policy Duration {} , "+
                          "validate result {}" ,
                          intDuration,
                          passwordPolicy.getDuration(), 
                          (intDuration > passwordPolicy.getDuration())
                    );
            if(intDuration >= passwordPolicy.getDuration()) {
                _logger.debug("resetAttempts ...");
                resetAttempts(userInfo);
            }else {
                lockUser(userInfo);
                throw new BadCredentialsException(
                        WebContext.getI18nValue("login.error.attempts",
                                new Object[]{userInfo.getBadPasswordCount(),passwordPolicy.getDuration()}) 
                        );
            }
        }
        if(userInfo.getIsLocked()==ConstantsStatus.LOCK) {
            throw new BadCredentialsException(
                                userInfo.getUsername()+ " "+
                                WebContext.getI18nValue("login.error.locked")
                                );
        }
        if(userInfo.getStatus()!=ConstantsStatus.ACTIVE) {
            throw new BadCredentialsException(
                                userInfo.getUsername()+ 
                                WebContext.getI18nValue("login.error.inactive") 
                                );
        }
        return true;
    }
public boolean passwordPolicyValid ( UserInfo userInfo ) { getPasswordPolicy ( ) ; DateTime currentdateTime = new DateTime ( ) ; /*
         * check login attempts fail times
         */ if ( userInfo . getBadPasswordCount ( ) >= passwordPolicy . getAttempts ( ) ) { _logger . debug ( "login Attempts is " + userInfo . getBadPasswordCount ( ) ) ; String badPasswordTimeString = userInfo . getBadPasswordTime ( ) . substring ( 0 , 19 ) ; _logger . trace ( "bad Password Time " + badPasswordTimeString ) ; DateTime badPasswordTime = DateTime . parse ( badPasswordTimeString , DateTimeFormat . forPattern ( "yyyy-MM-dd HH:mm:ss" ) ) ; Duration duration = new Duration ( badPasswordTime , currentdateTime ) ; int intDuration = Integer . parseInt ( duration . getStandardHours ( ) + "" ) ; _logger . debug ( "bad Password duration {} , " + "password policy Duration {} , " + "validate result {}" , intDuration , passwordPolicy . getDuration ( ) , ( intDuration > passwordPolicy . getDuration ( ) ) ) ; if ( intDuration >= passwordPolicy . getDuration ( ) ) { _logger . debug ( "resetAttempts ..." ) ; resetAttempts ( userInfo ) ; } else { lockUser ( userInfo ) ; throw new BadCredentialsException ( WebContext . getI18nValue ( "login.error.attempts" , new Object [ ] { userInfo . getBadPasswordCount ( ) , passwordPolicy . getDuration ( ) } ) ) ; } } if ( userInfo . getIsLocked ( ) == ConstantsStatus . LOCK ) { throw new BadCredentialsException ( userInfo . getUsername ( ) + " " + WebContext . getI18nValue ( "login.error.locked" ) ) ; } if ( userInfo . getStatus ( ) != ConstantsStatus . ACTIVE ) { throw new BadCredentialsException ( userInfo . getUsername ( ) + WebContext . getI18nValue ( "login.error.inactive" ) ) ; } return true ; }
dynamic passwordPolicy Valid for user login.
dynamic passwordPolicy Valid for user login .
//duration //auto unlock attempts when intDuration >= set Duration //locked // inactive