Search in sources :

Example 6 with Saml2AuthenticationRequestRepository

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

the class Saml2WebSsoAuthenticationFilter method setAuthenticationRequestRepositoryIntoAuthenticationConverter.

private void setAuthenticationRequestRepositoryIntoAuthenticationConverter(Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> authenticationRequestRepository) {
    if (this.authenticationConverter instanceof Saml2AuthenticationTokenConverter) {
        Saml2AuthenticationTokenConverter authenticationTokenConverter = (Saml2AuthenticationTokenConverter) this.authenticationConverter;
        authenticationTokenConverter.setAuthenticationRequestRepository(authenticationRequestRepository);
    }
}
Also used : Saml2AuthenticationTokenConverter(org.springframework.security.saml2.provider.service.web.Saml2AuthenticationTokenConverter)

Example 7 with Saml2AuthenticationRequestRepository

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

the class Saml2WebSsoAuthenticationFilterTests method attemptAuthenticationWhenSavedAuthnRequestThenRemovesAuthnRequest.

@Test
public void attemptAuthenticationWhenSavedAuthnRequestThenRemovesAuthnRequest() {
    Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> authenticationRequestRepository = mock(Saml2AuthenticationRequestRepository.class);
    AuthenticationConverter authenticationConverter = mock(AuthenticationConverter.class);
    given(authenticationConverter.convert(this.request)).willReturn(TestSaml2AuthenticationTokens.token());
    this.filter = new Saml2WebSsoAuthenticationFilter(authenticationConverter, "/some/other/path/{registrationId}");
    this.filter.setAuthenticationManager((authentication) -> null);
    this.request.setPathInfo("/some/other/path/idp-registration-id");
    this.filter.setAuthenticationRequestRepository(authenticationRequestRepository);
    this.filter.attemptAuthentication(this.request, this.response);
    verify(authenticationRequestRepository).removeAuthenticationRequest(this.request, this.response);
}
Also used : AuthenticationConverter(org.springframework.security.web.authentication.AuthenticationConverter) AbstractSaml2AuthenticationRequest(org.springframework.security.saml2.provider.service.authentication.AbstractSaml2AuthenticationRequest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 AbstractSaml2AuthenticationRequest (org.springframework.security.saml2.provider.service.authentication.AbstractSaml2AuthenticationRequest)6 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 Saml2AuthenticationTokenConverter (org.springframework.security.saml2.provider.service.web.Saml2AuthenticationTokenConverter)2 AuthenticationConverter (org.springframework.security.web.authentication.AuthenticationConverter)2 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)2 Saml2AuthenticationToken (org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken)1