use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class GeoLocationAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("107.181.69.221");
request.setLocalAddr("127.0.0.1");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isHighestRisk());
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class IpAddressAuthenticationRequestRiskCalculatorTests method verifyTestWhenNoAuthnEventsFoundForUser.
@Test
public void verifyTestWhenNoAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("nobody");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isHighestRisk());
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class IpAddressAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("107.181.69.221");
request.setLocalAddr("127.0.0.1");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isRiskGreaterThan(casProperties.getAuthn().getAdaptive().getRisk().getThreshold()));
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class UserAgentAuthenticationRequestRiskCalculatorTests method verifyTestWhenAuthnEventsFoundForUser.
@Test
public void verifyTestWhenAuthnEventsFoundForUser() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("casuser");
final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)");
request.setRemoteAddr("107.181.69.221");
request.setLocalAddr("127.0.0.1");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
assertTrue(score.isRiskGreaterThan(casProperties.getAuthn().getAdaptive().getRisk().getThreshold()));
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class DefaultSingleSignOnParticipationStrategy method isParticipating.
@Override
public boolean isParticipating(final RequestContext ctx) {
if (renewEnabled && ctx.getRequestParameters().contains(CasProtocolConstants.PARAMETER_RENEW)) {
LOGGER.debug("[{}] is specified for the request. The authentication session will be considered renewed.", CasProtocolConstants.PARAMETER_RENEW);
return this.createSsoSessionCookieOnRenewAuthentications;
}
final Authentication authentication = WebUtils.getAuthentication(ctx);
final Service service = WebUtils.getService(ctx);
if (service != null) {
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
if (registeredService != null) {
final Authentication ca = AuthenticationCredentialsThreadLocalBinder.getCurrentAuthentication();
try {
AuthenticationCredentialsThreadLocalBinder.bindCurrent(authentication);
final boolean isAllowedForSso = registeredService.getAccessStrategy().isServiceAccessAllowedForSso();
LOGGER.debug("Located [{}] in registry. Service access to participate in SSO is set to [{}]", registeredService.getServiceId(), isAllowedForSso);
return isAllowedForSso;
} finally {
AuthenticationCredentialsThreadLocalBinder.bindCurrent(ca);
}
}
}
return true;
}
Aggregations