Search in sources :

Example 1 with DefaultSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class ChainingSingleLogoutServiceLogoutUrlBuilderTests method verifyOperation.

@Test
public void verifyOperation() {
    val builder = new ChainingSingleLogoutServiceLogoutUrlBuilder(List.of(new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, SimpleUrlValidator.getInstance())));
    val service = CoreAuthenticationTestUtils.getWebApplicationService();
    val registeredService = mock(RegexRegisteredService.class);
    when(registeredService.matches(any(Service.class))).thenReturn(Boolean.TRUE);
    when(registeredService.getFriendlyName()).thenCallRealMethod();
    when(registeredService.getServiceId()).thenReturn(CoreAuthenticationTestUtils.CONST_TEST_URL);
    when(registeredService.matches(anyString())).thenReturn(Boolean.TRUE);
    when(registeredService.getAccessStrategy()).thenReturn(new DefaultRegisteredServiceAccessStrategy());
    when(registeredService.getLogoutUrl()).thenReturn("https://somewhere.org");
    servicesManager.save(registeredService);
    assertTrue(builder.supports(registeredService, service, Optional.empty()));
    assertTrue(builder.isServiceAuthorized(service, Optional.empty(), Optional.empty()));
    assertFalse(builder.determineLogoutUrl(registeredService, service, Optional.empty()).isEmpty());
}
Also used : lombok.val(lombok.val) ChainingSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Service(org.apereo.cas.authentication.principal.Service) DefaultRegisteredServiceAccessStrategy(org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class DefaultLogoutManagerTests method initialize.

@BeforeEach
public void initialize() {
    tgt = new MockTicketGrantingTicket("casuser");
    when(client.isValidEndPoint(any(String.class))).thenReturn(true);
    when(client.isValidEndPoint(any(URL.class))).thenReturn(true);
    when(client.sendMessageToEndPoint(any(HttpMessage.class))).thenReturn(true);
    val validator = new SimpleUrlValidatorFactoryBean(true).getObject();
    singleLogoutServiceMessageHandler = new DefaultSingleLogoutServiceMessageHandler(client, new DefaultSingleLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, validator), true, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    this.simpleWebApplicationServiceImpl = getService(URL);
    tgt.getServices().put(ID, this.simpleWebApplicationServiceImpl);
    val plan = new DefaultLogoutExecutionPlan();
    plan.registerSingleLogoutServiceMessageHandler(singleLogoutServiceMessageHandler);
    this.logoutManager = new DefaultLogoutManager(false, plan);
    this.registeredService = getRegisteredService(URL);
    when(servicesManager.findServiceBy(this.simpleWebApplicationServiceImpl)).thenReturn(this.registeredService);
    assertTrue(plan.getLogoutRedirectionStrategies().isEmpty());
}
Also used : lombok.val(lombok.val) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) DefaultSingleLogoutServiceMessageHandler(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceMessageHandler) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) URL(java.net.URL) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) SimpleUrlValidatorFactoryBean(org.apereo.cas.web.SimpleUrlValidatorFactoryBean) HttpMessage(org.apereo.cas.util.http.HttpMessage) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DefaultSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class SamlIdPSingleLogoutServiceLogoutUrlBuilderTests method verifyChainOperation.

@Test
public void verifyChainOperation() {
    val defaultBuilder = new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, SimpleUrlValidator.getInstance());
    val chain = new ChainingSingleLogoutServiceLogoutUrlBuilder(List.of(samlLogoutUrlBuilder, defaultBuilder));
    val samlRegisteredService = SamlIdPTestUtils.getSamlRegisteredService();
    samlRegisteredService.setLogoutType(RegisteredServiceLogoutType.FRONT_CHANNEL);
    val service = RegisteredServiceTestUtils.getService("https://mocky.io");
    val results = chain.determineLogoutUrl(samlRegisteredService, service);
    assertEquals(1, results.size());
    val res = results.iterator().next();
    assertTrue(res.getProperties().containsKey(SamlIdPSingleLogoutServiceLogoutUrlBuilder.PROPERTY_NAME_SINGLE_LOGOUT_BINDING));
}
Also used : lombok.val(lombok.val) ChainingSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultSingleLogoutServiceLogoutUrlBuilder

use of org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder in project cas by apereo.

the class DefaultSingleLogoutServiceMessageHandlerTests method verifyEmpty.

@Test
public void verifyEmpty() {
    val servicesManager = mock(ServicesManager.class);
    val service = new RegexRegisteredService();
    service.setServiceId(UUID.randomUUID().toString());
    when(servicesManager.findServiceBy(any(Service.class))).thenReturn(service);
    val handler = new DefaultSingleLogoutServiceMessageHandler(new SimpleHttpClientFactoryBean().getObject(), new DefaultSingleLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(servicesManager, mock(UrlValidator.class)), false, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
    assertTrue(handler.handle(CoreAuthenticationTestUtils.getWebApplicationService(), UUID.randomUUID().toString(), SingleLogoutExecutionRequest.builder().build()).isEmpty());
}
Also used : lombok.val(lombok.val) SimpleHttpClientFactoryBean(org.apereo.cas.util.http.SimpleHttpClientFactoryBean) DefaultAuthenticationServiceSelectionStrategy(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy) DefaultSingleLogoutServiceMessageHandler(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceMessageHandler) DefaultSingleLogoutServiceLogoutUrlBuilder(org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) Service(org.apereo.cas.authentication.principal.Service) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)4 DefaultSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.slo.DefaultSingleLogoutServiceLogoutUrlBuilder)4 Test (org.junit.jupiter.api.Test)3 DefaultAuthenticationServiceSelectionPlan (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan)2 DefaultAuthenticationServiceSelectionStrategy (org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionStrategy)2 Service (org.apereo.cas.authentication.principal.Service)2 ChainingSingleLogoutServiceLogoutUrlBuilder (org.apereo.cas.logout.slo.ChainingSingleLogoutServiceLogoutUrlBuilder)2 DefaultSingleLogoutServiceMessageHandler (org.apereo.cas.logout.slo.DefaultSingleLogoutServiceMessageHandler)2 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)2 URL (java.net.URL)1 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)1 DefaultRegisteredServiceAccessStrategy (org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy)1 HttpMessage (org.apereo.cas.util.http.HttpMessage)1 SimpleHttpClientFactoryBean (org.apereo.cas.util.http.SimpleHttpClientFactoryBean)1 SimpleUrlValidatorFactoryBean (org.apereo.cas.web.SimpleUrlValidatorFactoryBean)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1