use of org.springframework.security.saml2.provider.service.metadata.OpenSamlMetadataResolver in project spring-security by spring-projects.
the class OpenSamlMetadataResolverTests method resolveWhenRelyingPartyNameIDFormatThenMetadataMatches.
@Test
public void resolveWhenRelyingPartyNameIDFormatThenMetadataMatches() {
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.full().nameIdFormat("format").build();
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
assertThat(metadata).contains("<md:NameIDFormat>format</md:NameIDFormat>");
}
use of org.springframework.security.saml2.provider.service.metadata.OpenSamlMetadataResolver in project spring-security by spring-projects.
the class OpenSamlMetadataResolverTests method resolveWhenRelyingPartyNoLogoutThenMetadataMatches.
@Test
public void resolveWhenRelyingPartyNoLogoutThenMetadataMatches() {
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.full().singleLogoutServiceLocation(null).nameIdFormat("format").build();
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
assertThat(metadata).doesNotContain("ResponseLocation");
}
use of org.springframework.security.saml2.provider.service.metadata.OpenSamlMetadataResolver in project spring-security by spring-projects.
the class OpenSamlMetadataResolverTests method resolveWhenRelyingPartyNoCredentialsThenMetadataMatches.
@Test
public void resolveWhenRelyingPartyNoCredentialsThenMetadataMatches() {
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.noCredentials().assertingPartyDetails((party) -> party.verificationX509Credentials((c) -> c.add(TestSaml2X509Credentials.relyingPartyVerifyingCredential()))).build();
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
assertThat(metadata).contains("<EntityDescriptor").contains("entityID=\"rp-entity-id\"").doesNotContain("<md:KeyDescriptor use=\"signing\">").doesNotContain("<md:KeyDescriptor use=\"encryption\">").contains("Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\"").contains("Location=\"https://rp.example.org/acs\" index=\"1\"").contains("ResponseLocation=\"https://rp.example.org/logout/saml2/response\"");
}
use of org.springframework.security.saml2.provider.service.metadata.OpenSamlMetadataResolver in project midpoint by Evolveum.
the class SamlModuleWebSecurityConfigurer method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
MidpointSaml2LoginConfigurer configurer = new MidpointSaml2LoginConfigurer<>(auditProvider);
configurer.relyingPartyRegistrationRepository(relyingPartyRegistrations()).loginProcessingUrl(getConfiguration().getPrefixOfModule() + SamlModuleWebSecurityConfiguration.SSO_LOCATION_URL_SUFFIX).successHandler(getObjectPostProcessor().postProcess(new MidPointAuthenticationSuccessHandler())).failureHandler(new MidpointAuthenticationFailureHandler());
try {
configurer.authenticationManager(new ProviderManager(Collections.emptyList(), authenticationManager()));
} catch (Exception e) {
LOGGER.error("Couldn't initialize authentication manager for saml2 module");
}
getOrApply(http, configurer);
Saml2MetadataFilter filter = new Saml2MetadataFilter(new MidpointMetadataRelyingPartyRegistrationResolver(relyingPartyRegistrations()), new OpenSamlMetadataResolver());
filter.setRequestMatcher(new AntPathRequestMatcher(getConfiguration().getPrefixOfModule() + "/metadata/*"));
http.addFilterAfter(filter, Saml2WebSsoAuthenticationFilter.class);
}
use of org.springframework.security.saml2.provider.service.metadata.OpenSamlMetadataResolver in project spring-security by spring-projects.
the class OpenSamlMetadataResolverTests method resolveWhenRelyingPartyThenMetadataMatches.
@Test
public void resolveWhenRelyingPartyThenMetadataMatches() {
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.full().assertionConsumerServiceBinding(Saml2MessageBinding.REDIRECT).build();
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
assertThat(metadata).contains("<EntityDescriptor").contains("entityID=\"rp-entity-id\"").contains("<md:KeyDescriptor use=\"signing\">").contains("<md:KeyDescriptor use=\"encryption\">").contains("<ds:X509Certificate>MIICgTCCAeoCCQCuVzyqFgMSyDANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UEBh").contains("Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\"").contains("Location=\"https://rp.example.org/acs\" index=\"1\"").contains("ResponseLocation=\"https://rp.example.org/logout/saml2/response\"");
}
Aggregations