Search in sources :

Example 6 with GeoLocationResponse

use of org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse in project cas by apereo.

the class AdaptiveMultifactorAuthenticationPolicyEventResolver method checkRequestGeoLocation.

private boolean checkRequestGeoLocation(final String clientIp, final String mfaMethod, final String pattern) {
    if (this.geoLocationService != null) {
        final GeoLocationRequest location = WebUtils.getHttpServletRequestGeoLocation();
        final GeoLocationResponse loc = this.geoLocationService.locate(clientIp, location);
        if (loc != null) {
            final String 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;
}
Also used : GeoLocationResponse(org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse) GeoLocationRequest(org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest)

Aggregations

GeoLocationResponse (org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse)6 GeoLocationRequest (org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 GaeRequestHandler (com.google.maps.GaeRequestHandler)1 GeoApiContext (com.google.maps.GeoApiContext)1 GeocodingApi (com.google.maps.GeocodingApi)1 GeocodingResult (com.google.maps.model.GeocodingResult)1 LatLng (com.google.maps.model.LatLng)1 AddressNotFoundException (com.maxmind.geoip2.exception.AddressNotFoundException)1 CityResponse (com.maxmind.geoip2.model.CityResponse)1 CountryResponse (com.maxmind.geoip2.model.CountryResponse)1 UserInfo (io.userinfo.client.UserInfo)1 Info (io.userinfo.client.model.Info)1 BigDecimal (java.math.BigDecimal)1 InetAddress (java.net.InetAddress)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 TimeUnit (java.util.concurrent.TimeUnit)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1