Search in sources :

Example 56 with RegisteredService

use of org.apereo.cas.services.RegisteredService in project cas by apereo.

the class DateTimeAuthenticationRequestRiskCalculatorTests method verifyTestWhenNoAuthnEventsFoundForUser.

@Test
public void verifyTestWhenNoAuthnEventsFoundForUser() {
    final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication("datetimeperson");
    final RegisteredService service = RegisteredServiceTestUtils.getRegisteredService("test");
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final AuthenticationRiskScore score = authenticationRiskEvaluator.eval(authentication, service, request);
    assertTrue(score.isHighestRisk());
}
Also used : AuthenticationRiskScore(org.apereo.cas.api.AuthenticationRiskScore) RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 57 with RegisteredService

use of org.apereo.cas.services.RegisteredService 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());
}
Also used : AuthenticationRiskScore(org.apereo.cas.api.AuthenticationRiskScore) RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) Test(org.junit.Test)

Example 58 with RegisteredService

use of org.apereo.cas.services.RegisteredService 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());
}
Also used : AuthenticationRiskScore(org.apereo.cas.api.AuthenticationRiskScore) RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 59 with RegisteredService

use of org.apereo.cas.services.RegisteredService 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()));
}
Also used : AuthenticationRiskScore(org.apereo.cas.api.AuthenticationRiskScore) RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) Test(org.junit.Test)

Example 60 with RegisteredService

use of org.apereo.cas.services.RegisteredService 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()));
}
Also used : AuthenticationRiskScore(org.apereo.cas.api.AuthenticationRiskScore) RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) Test(org.junit.Test)

Aggregations

RegisteredService (org.apereo.cas.services.RegisteredService)182 Authentication (org.apereo.cas.authentication.Authentication)59 Service (org.apereo.cas.authentication.principal.Service)55 Test (org.junit.Test)49 Principal (org.apereo.cas.authentication.principal.Principal)36 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)31 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)29 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)23 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)21 MultifactorAuthenticationProvider (org.apereo.cas.services.MultifactorAuthenticationProvider)20 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)20 Event (org.springframework.webflow.execution.Event)20 ServicesManager (org.apereo.cas.services.ServicesManager)17 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)15 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)15 Map (java.util.Map)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 Slf4j (lombok.extern.slf4j.Slf4j)14 Collection (java.util.Collection)13 HashMap (java.util.HashMap)12