use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class TimedMultifactorAuthenticationPolicyEventResolverTests method initialize.
@BeforeEach
public void initialize() {
this.context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("195.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class AdaptiveMultifactorAuthenticationPolicyEventResolverTests method verifyOperationNeedsMfaByGeo.
@Test
public void verifyOperationNeedsMfaByGeo() {
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "FIREFOX");
request.addParameter("geolocation", "1000,1000,1000,1000");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val event = resolver.resolve(context);
assertEquals(1, event.size());
assertEquals(TestMultifactorAuthenticationProvider.ID, event.iterator().next().getId());
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class DefaultCasCookieValueManagerTests method verifySessionPinning.
@Test
public void verifySessionPinning() {
val request = new MockHttpServletRequest();
request.setRemoteAddr(CLIENT_IP);
request.setLocalAddr(CLIENT_IP);
request.removeHeader("User-Agent");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val props = new TicketGrantingCookieProperties();
assertThrows(IllegalStateException.class, () -> new DefaultCasCookieValueManager(CipherExecutor.noOp(), props).buildCookieValue(VALUE, request));
props.setPinToSession(false);
assertNotNull(new DefaultCasCookieValueManager(CipherExecutor.noOp(), props).buildCookieValue(VALUE, request));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class DefaultCasCookieValueManagerTests method verifySessionPinningAuthorizedOnFailure.
@Test
public void verifySessionPinningAuthorizedOnFailure() {
val request = new MockHttpServletRequest();
request.setRemoteAddr(CLIENT_IP);
request.setLocalAddr(CLIENT_IP);
request.addHeader("User-Agent", USER_AGENT);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val props = new TicketGrantingCookieProperties();
props.setAllowedIpAddressesPattern("^19.*.3.1\\d\\d");
val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
var value = mgr.buildCookieValue(VALUE, request);
assertNotNull(value);
request.setRemoteAddr("198.127.3.155");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
value = mgr.obtainCookieValue(value, request);
assertNotNull(value);
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class DefaultCasCookieValueManagerTests method initialize.
@BeforeEach
public void initialize() {
MockitoAnnotations.openMocks(this);
val request = new MockHttpServletRequest();
request.setRemoteAddr(CLIENT_IP);
request.setLocalAddr(CLIENT_IP);
request.addHeader("User-Agent", USER_AGENT);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
cookieValueManager = new DefaultCasCookieValueManager(CipherExecutor.noOp(), new TicketGrantingCookieProperties());
}
Aggregations