private void blockBySessionOrIpFailedLoginAttempts(final String sessionId, final LoginBlockResultImpl loginBlockResultImpl) {
    """
	Block by session or ip failed login attempts.
	
	@param sessionId
	the session id
	@param loginBlockResultImpl
	the login block result impl
    """
		final ApplicationSession applicationSession = applicationSessionDAO
				.findFirstByProperty(ApplicationSession_.sessionId, sessionId);

		if (applicationSession != null) {

			final ApplicationConfiguration maxLoginAttemptsBySession = applicationConfigurationService.checkValueOrLoadDefault(MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_SESSION, BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED, ConfigurationGroup.AUTHENTICATION, LoginBlockedAccessImpl.class.getSimpleName(), LOGIN_BLOCKER, BLOCKS_LOGIN_ATTEMPTS, APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_SESSION,DEFAULT_MAX_LOGIN_ATTEMPTS);
			final List<ApplicationActionEvent> failedLoginsByThisSession = applicationActionEventDAO.findListByProperty(
					new Object[] { sessionId, ApplicationOperationType.AUTHENTICATION,
							ServiceResult.FAILURE.toString() },
					ApplicationActionEvent_.sessionId, ApplicationActionEvent_.applicationOperation,
					ApplicationActionEvent_.applicationMessage);
			if (failedLoginsByThisSession.size() > NumberUtils.toInt(maxLoginAttemptsBySession.getPropertyValue(),DEFAULT_MAX_LOGINS)) {
				loginBlockResultImpl.setBlocked(true);
				loginBlockResultImpl.addMessages(BLOCKED_BY_MORE_THAN_5_LOGIN_ATTEMPTS_BY_THIS_SESSION);
			}

			if (!("0:0:0:0:0:0:0:1".equals(applicationSession.getIpInformation()) || "127.0.0.1".equals(applicationSession.getIpInformation()))) {

				final List<ApplicationSession> applicationSessionsByIp = applicationSessionDAO
						.findListByProperty(ApplicationSession_.ipInformation, applicationSession.getIpInformation());

				final List<String> sessionIdsWithIp = applicationSessionsByIp.stream().map(ApplicationSession::getSessionId)
						.collect(Collectors.toList());

				final List<ApplicationActionEvent> applicationEventsWithIp = applicationActionEventDAO
						.findListByPropertyInList(ApplicationActionEvent_.sessionId,
								sessionIdsWithIp.toArray(new Object[sessionIdsWithIp.size()]));

				final Date oneHourAgo = new Date(System.currentTimeMillis() - ONE_HOUR);
				final Map<Boolean, List<ApplicationActionEvent>> recentOldLoginAttemptsMap = applicationEventsWithIp
						.stream()
						.filter((final ApplicationActionEvent x) -> x.getApplicationOperation() == ApplicationOperationType.AUTHENTICATION
								&& x.getApplicationMessage().equals(ServiceResult.FAILURE.toString()))
						.collect(Collectors.groupingBy((final ApplicationActionEvent x) -> x.getCreatedDate().after(oneHourAgo)));
				final List<ApplicationActionEvent> recentFailedLogins = recentOldLoginAttemptsMap
						.get(Boolean.TRUE);

				final ApplicationConfiguration maxLoginAttemptsByIp = applicationConfigurationService.checkValueOrLoadDefault(MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_IP, BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED, ConfigurationGroup.AUTHENTICATION, LoginBlockedAccessImpl.class.getSimpleName(), LOGIN_BLOCKER, BLOCKS_LOGIN_ATTEMPTS, APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_IP, DEFAULT_MAX_LOGIN_ATTEMPTS);
				if (recentFailedLogins != null && recentFailedLogins.size() > NumberUtils.toInt(maxLoginAttemptsByIp.getPropertyValue(),DEFAULT_MAX_LOGINS_BY_IP)) {
					loginBlockResultImpl.setBlocked(true);
					loginBlockResultImpl.addMessages(BLOCKED_BY_MORE_THAN_5_RECENT_LOGIN_ATTEMPTS_BY_THIS_IP);
				}
			}
		}
	}
private void blockBySessionOrIpFailedLoginAttempts(final String sessionId, final LoginBlockResultImpl loginBlockResultImpl) {
		final ApplicationSession applicationSession = applicationSessionDAO
				.findFirstByProperty(ApplicationSession_.sessionId, sessionId);

		if (applicationSession != null) {

			final ApplicationConfiguration maxLoginAttemptsBySession = applicationConfigurationService.checkValueOrLoadDefault(MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_SESSION, BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED, ConfigurationGroup.AUTHENTICATION, LoginBlockedAccessImpl.class.getSimpleName(), LOGIN_BLOCKER, BLOCKS_LOGIN_ATTEMPTS, APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_SESSION,DEFAULT_MAX_LOGIN_ATTEMPTS);
			final List<ApplicationActionEvent> failedLoginsByThisSession = applicationActionEventDAO.findListByProperty(
					new Object[] { sessionId, ApplicationOperationType.AUTHENTICATION,
							ServiceResult.FAILURE.toString() },
					ApplicationActionEvent_.sessionId, ApplicationActionEvent_.applicationOperation,
					ApplicationActionEvent_.applicationMessage);
			if (failedLoginsByThisSession.size() > NumberUtils.toInt(maxLoginAttemptsBySession.getPropertyValue(),DEFAULT_MAX_LOGINS)) {
				loginBlockResultImpl.setBlocked(true);
				loginBlockResultImpl.addMessages(BLOCKED_BY_MORE_THAN_5_LOGIN_ATTEMPTS_BY_THIS_SESSION);
			}

			if (!("0:0:0:0:0:0:0:1".equals(applicationSession.getIpInformation()) || "127.0.0.1".equals(applicationSession.getIpInformation()))) {

				final List<ApplicationSession> applicationSessionsByIp = applicationSessionDAO
						.findListByProperty(ApplicationSession_.ipInformation, applicationSession.getIpInformation());

				final List<String> sessionIdsWithIp = applicationSessionsByIp.stream().map(ApplicationSession::getSessionId)
						.collect(Collectors.toList());

				final List<ApplicationActionEvent> applicationEventsWithIp = applicationActionEventDAO
						.findListByPropertyInList(ApplicationActionEvent_.sessionId,
								sessionIdsWithIp.toArray(new Object[sessionIdsWithIp.size()]));

				final Date oneHourAgo = new Date(System.currentTimeMillis() - ONE_HOUR);
				final Map<Boolean, List<ApplicationActionEvent>> recentOldLoginAttemptsMap = applicationEventsWithIp
						.stream()
						.filter((final ApplicationActionEvent x) -> x.getApplicationOperation() == ApplicationOperationType.AUTHENTICATION
								&& x.getApplicationMessage().equals(ServiceResult.FAILURE.toString()))
						.collect(Collectors.groupingBy((final ApplicationActionEvent x) -> x.getCreatedDate().after(oneHourAgo)));
				final List<ApplicationActionEvent> recentFailedLogins = recentOldLoginAttemptsMap
						.get(Boolean.TRUE);

				final ApplicationConfiguration maxLoginAttemptsByIp = applicationConfigurationService.checkValueOrLoadDefault(MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_IP, BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED, ConfigurationGroup.AUTHENTICATION, LoginBlockedAccessImpl.class.getSimpleName(), LOGIN_BLOCKER, BLOCKS_LOGIN_ATTEMPTS, APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_IP, DEFAULT_MAX_LOGIN_ATTEMPTS);
				if (recentFailedLogins != null && recentFailedLogins.size() > NumberUtils.toInt(maxLoginAttemptsByIp.getPropertyValue(),DEFAULT_MAX_LOGINS_BY_IP)) {
					loginBlockResultImpl.setBlocked(true);
					loginBlockResultImpl.addMessages(BLOCKED_BY_MORE_THAN_5_RECENT_LOGIN_ATTEMPTS_BY_THIS_IP);
				}
			}
		}
	}
private void blockBySessionOrIpFailedLoginAttempts ( final String sessionId , final LoginBlockResultImpl loginBlockResultImpl ) { final ApplicationSession applicationSession = applicationSessionDAO . findFirstByProperty ( ApplicationSession_ . sessionId , sessionId ) ; if ( applicationSession != null ) { final ApplicationConfiguration maxLoginAttemptsBySession = applicationConfigurationService . checkValueOrLoadDefault ( MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_SESSION , BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED , ConfigurationGroup . AUTHENTICATION , LoginBlockedAccessImpl . class . getSimpleName ( ) , LOGIN_BLOCKER , BLOCKS_LOGIN_ATTEMPTS , APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_SESSION , DEFAULT_MAX_LOGIN_ATTEMPTS ) ; final List < ApplicationActionEvent > failedLoginsByThisSession = applicationActionEventDAO . findListByProperty ( new Object [ ] { sessionId , ApplicationOperationType . AUTHENTICATION , ServiceResult . FAILURE . toString ( ) } , ApplicationActionEvent_ . sessionId , ApplicationActionEvent_ . applicationOperation , ApplicationActionEvent_ . applicationMessage ) ; if ( failedLoginsByThisSession . size ( ) > NumberUtils . toInt ( maxLoginAttemptsBySession . getPropertyValue ( ) , DEFAULT_MAX_LOGINS ) ) { loginBlockResultImpl . setBlocked ( true ) ; loginBlockResultImpl . addMessages ( BLOCKED_BY_MORE_THAN_5_LOGIN_ATTEMPTS_BY_THIS_SESSION ) ; } if ( ! ( "0:0:0:0:0:0:0:1" . equals ( applicationSession . getIpInformation ( ) ) || "127.0.0.1" . equals ( applicationSession . getIpInformation ( ) ) ) ) { final List < ApplicationSession > applicationSessionsByIp = applicationSessionDAO . findListByProperty ( ApplicationSession_ . ipInformation , applicationSession . getIpInformation ( ) ) ; final List < String > sessionIdsWithIp = applicationSessionsByIp . stream ( ) . map ( ApplicationSession :: getSessionId ) . collect ( Collectors . toList ( ) ) ; final List < ApplicationActionEvent > applicationEventsWithIp = applicationActionEventDAO . findListByPropertyInList ( ApplicationActionEvent_ . sessionId , sessionIdsWithIp . toArray ( new Object [ sessionIdsWithIp . size ( ) ] ) ) ; final Date oneHourAgo = new Date ( System . currentTimeMillis ( ) - ONE_HOUR ) ; final Map < Boolean , List < ApplicationActionEvent > > recentOldLoginAttemptsMap = applicationEventsWithIp . stream ( ) . filter ( ( final ApplicationActionEvent x ) -> x . getApplicationOperation ( ) == ApplicationOperationType . AUTHENTICATION && x . getApplicationMessage ( ) . equals ( ServiceResult . FAILURE . toString ( ) ) ) . collect ( Collectors . groupingBy ( ( final ApplicationActionEvent x ) -> x . getCreatedDate ( ) . after ( oneHourAgo ) ) ) ; final List < ApplicationActionEvent > recentFailedLogins = recentOldLoginAttemptsMap . get ( Boolean . TRUE ) ; final ApplicationConfiguration maxLoginAttemptsByIp = applicationConfigurationService . checkValueOrLoadDefault ( MAX_FAILED_LOGIN_ATTEMPTS_RECENT_HOUR_PER_IP , BLOCKS_ANY_LOGIN_ATTEMPTS_AFTER_THIS_NUMBER_IS_REACHED , ConfigurationGroup . AUTHENTICATION , LoginBlockedAccessImpl . class . getSimpleName ( ) , LOGIN_BLOCKER , BLOCKS_LOGIN_ATTEMPTS , APPLICATION_AUTHENTICATION_ALLOW_MAX_RECENT_FAILED_LOGINS_BY_IP , DEFAULT_MAX_LOGIN_ATTEMPTS ) ; if ( recentFailedLogins != null && recentFailedLogins . size ( ) > NumberUtils . toInt ( maxLoginAttemptsByIp . getPropertyValue ( ) , DEFAULT_MAX_LOGINS_BY_IP ) ) { loginBlockResultImpl . setBlocked ( true ) ; loginBlockResultImpl . addMessages ( BLOCKED_BY_MORE_THAN_5_RECENT_LOGIN_ATTEMPTS_BY_THIS_IP ) ; } } } }
Block by session or ip failed login attempts.

@param sessionId
the session id
@param loginBlockResultImpl
the login block result impl
Block by session or ip failed login attempts .