/** * Gets http servlet request geo location. * * @param servletRequest the servlet request * @return the http servlet request geo location */ public static GeoLocationRequest getHttpServletRequestGeoLocation(final HttpServletRequest servletRequest) { if (servletRequest != null) { return HttpRequestUtils.getHttpServletRequestGeoLocation(servletRequest); } return null; }
private boolean checkRequestGeoLocation(final HttpServletRequest httpServletRequest, final String clientIp, final String mfaMethod, final String pattern) { if (this.geoLocationService != null) { val location = HttpRequestUtils.getHttpServletRequestGeoLocation(httpServletRequest); val loc = this.geoLocationService.locate(clientIp, location); if (loc != null) { val address = loc.build(); if (address.matches(pattern)) { LOGGER.debug("Current address [{}] at [{}] matches the provided pattern [{}] for " + "adaptive authentication and is required to use [{}]", address, clientIp, pattern, mfaMethod); return true; } } } return false; } }