Search in sources :

Example 1 with OpenSaml4LogoutRequestResolver

use of org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml4LogoutRequestResolver in project spring-security by spring-projects.

the class OpenSaml4LogoutRequestResolverTests method resolveWhenCustomParametersConsumerThenUses.

@Test
public void resolveWhenCustomParametersConsumerThenUses() {
    OpenSaml4LogoutRequestResolver logoutRequestResolver = new OpenSaml4LogoutRequestResolver(this.relyingPartyRegistrationResolver);
    logoutRequestResolver.setParametersConsumer((parameters) -> parameters.getLogoutRequest().setID("myid"));
    HttpServletRequest request = new MockHttpServletRequest();
    RelyingPartyRegistration registration = TestRelyingPartyRegistrations.relyingPartyRegistration().assertingPartyDetails((party) -> party.singleLogoutServiceLocation("https://ap.example.com/logout")).build();
    Authentication authentication = new TestingAuthenticationToken("user", "password");
    given(this.relyingPartyRegistrationResolver.resolve(any(), any())).willReturn(registration);
    Saml2LogoutRequest logoutRequest = logoutRequestResolver.resolve(request, authentication);
    assertThat(logoutRequest.getId()).isEqualTo("myid");
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) RelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Test(org.junit.jupiter.api.Test) BDDMockito.given(org.mockito.BDDMockito.given) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Authentication(org.springframework.security.core.Authentication) Saml2LogoutRequest(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutRequest) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) Mockito.mock(org.mockito.Mockito.mock) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Authentication(org.springframework.security.core.Authentication) Saml2LogoutRequest(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutRequest) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.jupiter.api.Test)

Example 2 with OpenSaml4LogoutRequestResolver

use of org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml4LogoutRequestResolver in project midpoint by Evolveum.

the class SamlModuleWebSecurityConfigurer method getLogoutRequestSuccessHandler.

@Override
protected LogoutSuccessHandler getLogoutRequestSuccessHandler() {
    RelyingPartyRegistrationResolver registrationResolver = new DefaultRelyingPartyRegistrationResolver(relyingPartyRegistrations());
    Saml2LogoutRequestResolver logoutRequestResolver = new MidpointSaml2LogoutRequestResolver(new OpenSaml4LogoutRequestResolver(registrationResolver));
    Saml2RelyingPartyInitiatedLogoutSuccessHandler handler = new Saml2RelyingPartyInitiatedLogoutSuccessHandler(logoutRequestResolver);
    return getObjectPostProcessor().postProcess(new MidpointSaml2LogoutRequestSuccessHandler(handler));
}
Also used : MidpointSaml2LogoutRequestResolver(com.evolveum.midpoint.authentication.impl.saml.MidpointSaml2LogoutRequestResolver) Saml2LogoutRequestResolver(org.springframework.security.saml2.provider.service.web.authentication.logout.Saml2LogoutRequestResolver) MidpointSaml2LogoutRequestResolver(com.evolveum.midpoint.authentication.impl.saml.MidpointSaml2LogoutRequestResolver) MidpointMetadataRelyingPartyRegistrationResolver(com.evolveum.midpoint.authentication.impl.saml.MidpointMetadataRelyingPartyRegistrationResolver) DefaultRelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.DefaultRelyingPartyRegistrationResolver) RelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver) DefaultRelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.DefaultRelyingPartyRegistrationResolver) OpenSaml4LogoutRequestResolver(org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml4LogoutRequestResolver) MidpointSaml2LogoutRequestSuccessHandler(com.evolveum.midpoint.authentication.impl.saml.MidpointSaml2LogoutRequestSuccessHandler) Saml2RelyingPartyInitiatedLogoutSuccessHandler(org.springframework.security.saml2.provider.service.web.authentication.logout.Saml2RelyingPartyInitiatedLogoutSuccessHandler)

Aggregations

RelyingPartyRegistrationResolver (org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver)2 MidpointMetadataRelyingPartyRegistrationResolver (com.evolveum.midpoint.authentication.impl.saml.MidpointMetadataRelyingPartyRegistrationResolver)1 MidpointSaml2LogoutRequestResolver (com.evolveum.midpoint.authentication.impl.saml.MidpointSaml2LogoutRequestResolver)1 MidpointSaml2LogoutRequestSuccessHandler (com.evolveum.midpoint.authentication.impl.saml.MidpointSaml2LogoutRequestSuccessHandler)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 BDDMockito.given (org.mockito.BDDMockito.given)1 Mockito.mock (org.mockito.Mockito.mock)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1 Saml2LogoutRequest (org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutRequest)1 RelyingPartyRegistration (org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration)1 TestRelyingPartyRegistrations (org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations)1 DefaultRelyingPartyRegistrationResolver (org.springframework.security.saml2.provider.service.web.DefaultRelyingPartyRegistrationResolver)1 OpenSaml4LogoutRequestResolver (org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml4LogoutRequestResolver)1 Saml2LogoutRequestResolver (org.springframework.security.saml2.provider.service.web.authentication.logout.Saml2LogoutRequestResolver)1