use of org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal in project spring-security by spring-projects.
the class Saml2LogoutConfigurerTests method saml2LogoutWhenNoRegistrationThen401.
@Test
public void saml2LogoutWhenNoRegistrationThen401() throws Exception {
this.spring.register(Saml2LogoutDefaultsConfig.class).autowire();
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", Collections.emptyMap());
principal.setRelyingPartyRegistrationId("wrong");
Saml2Authentication authentication = new Saml2Authentication(principal, "response", AuthorityUtils.createAuthorityList("ROLE_USER"));
this.mvc.perform(post("/logout").with(authentication(authentication)).with(csrf())).andExpect(status().isUnauthorized());
}
use of org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal in project spring-security by spring-projects.
the class Saml2LogoutConfigurerTests method saml2LogoutRequestWhenDefaultsThenLogsOutAndSendsLogoutResponse.
@Test
public void saml2LogoutRequestWhenDefaultsThenLogsOutAndSendsLogoutResponse() throws Exception {
this.spring.register(Saml2LogoutDefaultsConfig.class).autowire();
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", Collections.emptyMap());
principal.setRelyingPartyRegistrationId("get");
Saml2Authentication user = new Saml2Authentication(principal, "response", AuthorityUtils.createAuthorityList("ROLE_USER"));
MvcResult result = this.mvc.perform(get("/logout/saml2/slo").param("SAMLRequest", this.apLogoutRequest).param("RelayState", this.apLogoutRequestRelayState).param("SigAlg", this.apLogoutRequestSigAlg).param("Signature", this.apLogoutRequestSignature).with(authentication(user))).andExpect(status().isFound()).andReturn();
String location = result.getResponse().getHeader("Location");
assertThat(location).startsWith("https://ap.example.org/logout/saml2/response");
verify(getBean(LogoutHandler.class)).logout(any(), any(), any());
}
use of org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal in project spring-security by spring-projects.
the class OpenSamlLogoutResponseResolverTests method authentication.
private Saml2Authentication authentication(RelyingPartyRegistration registration) {
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", new HashMap<>());
principal.setRelyingPartyRegistrationId(registration.getRegistrationId());
return new Saml2Authentication(principal, "response", new ArrayList<>());
}
use of org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal in project spring-security by spring-projects.
the class Saml2RelyingPartyInitiatedLogoutSuccessHandlerTests method authentication.
private Saml2Authentication authentication(RelyingPartyRegistration registration) {
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", new HashMap<>());
principal.setRelyingPartyRegistrationId(registration.getRegistrationId());
return new Saml2Authentication(principal, "response", new ArrayList<>());
}
use of org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal in project spring-security by spring-projects.
the class OpenSamlLogoutRequestResolverTests method authentication.
private Saml2Authentication authentication(RelyingPartyRegistration registration) {
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", new HashMap<>(), Arrays.asList("session-index"));
principal.setRelyingPartyRegistrationId(registration.getRegistrationId());
return new Saml2Authentication(principal, "response", new ArrayList<>());
}
Aggregations