Package net.webpasswordsafe.common.model

Examples of net.webpasswordsafe.common.model.IPLockout


    {
        boolean isAuthSuccess = false;
        boolean isLockedOut = false;
        Date dateNow = new Date();
        String ipaddress = ServerSessionUtil.getIP();
        IPLockout lockout = ipLockoutDAO.findByIP(ipaddress);
        if (!isWhitelistIP(ipaddress))
        {
            if ((null != lockout) && (null != lockout.getLockoutDate()))
            {
                isLockedOut = true;
                Date endLockout = new Date(lockout.getLockoutDate().getTime() + (lockoutLength * 60000));
                if (dateNow.getTime() > endLockout.getTime())
                {
                    isLockedOut = false;
                    lockout.setLockoutDate(null);
                }
            }
        }
       
        if (!isLockedOut)
        {
            isAuthSuccess = authenticator.authenticate(username, password);
            if (!isWhitelistIP(ipaddress))
            {
                if (!isAuthSuccess)
                {
                    lockout = (null == lockout) ? new IPLockout(ipaddress, 0) : lockout;
                    int failCount = lockout.getFailCount() + 1;
                    if (failCount >= failedLoginThreshold)
                    {
                        lockout.setFailCount(0);
                        lockout.setLockoutDate(dateNow);
                        LOG.debug("IPLockoutAuthenticator: "+ipaddress+" is locked out");
                        auditLogger.log(dateNow, username, ipaddress, "lockout", ipaddress, true, "IP blocked");
                    }
                    else
                    {
                        lockout.setFailCount(failCount);
                    }
                    ipLockoutDAO.makePersistent(lockout);
                }
                else
                {
                    if (null != lockout)
                    {
                        lockout.setFailCount(0);
                    }
                }
            }
        }

View Full Code Here


        Date now = new Date();
        String action = "unblock ip";
        User loggedInUser = getLoggedInUser();
        if (authorizer.isAuthorized(loggedInUser, Function.UNBLOCK_IP.name()))
        {
            IPLockout ipLockout = ipLockoutDAO.findByIP(ipaddress);
            if ((null != ipLockout) && (null != ipLockout.getLockoutDate()))
            {
                ipLockout.setLockoutDate(null);
                ipLockout.setFailCount(0);
                isUnblocked = true;
                auditLogger.log(now, ServerSessionUtil.getUsername(), ServerSessionUtil.getIP(), action, ipaddress, true, "");
            }
            else
            {
View Full Code Here

TOP

Related Classes of net.webpasswordsafe.common.model.IPLockout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.