use of org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest in project cas by apereo.
the class DefaultAdaptiveAuthenticationPolicyTests method verifyActionWithNoClientInfo.
@Test
public void verifyActionWithNoClientInfo() {
val props = new AdaptiveAuthenticationProperties();
val service = mock(GeoLocationService.class);
val p = new DefaultAdaptiveAuthenticationPolicy(service, IPAddressIntelligenceService.allowed(), props);
assertTrue(p.apply(new MockRequestContext(), "something", new GeoLocationRequest()));
}
use of org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest in project cas by apereo.
the class GeoLocationServiceTests method verifyLocate.
@Test
public void verifyLocate() {
HttpsURLConnection.setDefaultHostnameVerifier(CasSSLContext.disabled().getHostnameVerifier());
HttpsURLConnection.setDefaultSSLSocketFactory(CasSSLContext.disabled().getSslContext().getSocketFactory());
val svc = new DummyGeoLocationService();
assertNotNull(svc.locate("1.2.3.4", new GeoLocationRequest(1, 1)));
assertNotNull(svc.locate(new GeoLocationRequest(1, 1)));
}
use of org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest in project cas by apereo.
the class HttpRequestUtils method getHttpServletRequestGeoLocation.
/**
* Gets http servlet request geo location.
*
* @param geoLocationParam the geo location param
* @return the http servlet request geo location
*/
public static GeoLocationRequest getHttpServletRequestGeoLocation(final String geoLocationParam) {
val loc = new GeoLocationRequest();
if (StringUtils.isNotBlank(geoLocationParam) && !StringUtils.equalsIgnoreCase(geoLocationParam, "unknown")) {
val geoLocation = Splitter.on(",").splitToList(geoLocationParam);
loc.setLatitude(geoLocation.get(GEO_LOC_LAT_INDEX));
loc.setLongitude(geoLocation.get(GEO_LOC_LONG_INDEX));
loc.setAccuracy(geoLocation.get(GEO_LOC_ACCURACY_INDEX));
loc.setTimestamp(geoLocation.get(GEO_LOC_TIME_INDEX));
}
return loc;
}
use of org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest in project cas by apereo.
the class InfluxDbCasEventRepository method load.
@Override
public Stream<? extends CasEvent> load() {
val results = influxDbConnectionFactory.query(InfluxDbEvent.class);
return results.stream().map(flux -> {
val event = new CasEvent();
val geo = Unchecked.supplier(() -> MAPPER.readValue(flux.getGeoLocation(), new TypeReference<GeoLocationRequest>() {
})).get();
event.putGeoLocation(geo);
event.setPrincipalId(flux.getPrincipalId());
event.setType(flux.getType());
event.setCreationTime(flux.getCreationTime());
event.putClientIpAddress(flux.getClientIpAddress());
event.putServerIpAddress(flux.getServerIpAddress());
event.putEventId(flux.getValue());
event.putTimestamp(Long.valueOf(flux.getTimestamp()));
return event;
});
}
use of org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest in project cas by apereo.
the class AbstractCasEventRepositoryTests method getCasEvent.
private CasEvent getCasEvent(final String user) {
val ticket = new MockTicketGrantingTicket(user);
val event = new CasTicketGrantingTicketCreatedEvent(this, ticket);
val dto = new CasEvent();
dto.setType(event.getClass().getCanonicalName());
dto.putTimestamp(event.getTimestamp());
dto.setCreationTime(event.getTicketGrantingTicket().getCreationTime().format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
dto.putEventId(event.getTicketGrantingTicket().getId());
dto.putClientIpAddress("1.2.3.4");
dto.putServerIpAddress("1.2.3.4");
val location = new GeoLocationRequest(1234, 1234);
location.setAccuracy("80");
location.setTimestamp(String.valueOf(event.getTimestamp()));
dto.putGeoLocation(location);
dto.setPrincipalId(event.getTicketGrantingTicket().getAuthentication().getPrincipal().getId());
return dto;
}
Aggregations