|
@@ -18,18 +18,20 @@ package org.springframework.security.saml2.provider.service.registration;
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
-import org.springframework.security.saml2.credentials.Saml2X509Credential;
|
|
|
import org.springframework.security.saml2.provider.service.servlet.filter.Saml2WebSsoAuthenticationFilter;
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
-import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartySigningCredential;
|
|
|
-import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyVerifyingCredential;
|
|
|
+import static org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding.POST;
|
|
|
+import static org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations.relyingPartyRegistration;
|
|
|
|
|
|
public class RelyingPartyRegistrationTests {
|
|
|
|
|
|
@Test
|
|
|
public void withRelyingPartyRegistrationWorks() {
|
|
|
- RelyingPartyRegistration registration = relyingPartyRegistration();
|
|
|
+ RelyingPartyRegistration registration = relyingPartyRegistration()
|
|
|
+ .providerDetails(p -> p.binding(POST))
|
|
|
+ .providerDetails(p -> p.signAuthNRequest(false))
|
|
|
+ .build();
|
|
|
RelyingPartyRegistration copy = RelyingPartyRegistration.withRelyingPartyRegistration(registration).build();
|
|
|
compareRegistrations(registration, copy);
|
|
|
}
|
|
@@ -58,38 +60,9 @@ public class RelyingPartyRegistrationTests {
|
|
|
.isEqualTo("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php");
|
|
|
assertThat(copy.getProviderDetails().getBinding())
|
|
|
.isEqualTo(registration.getProviderDetails().getBinding())
|
|
|
- .isEqualTo(Saml2MessageBinding.POST);
|
|
|
+ .isEqualTo(POST);
|
|
|
assertThat(copy.getProviderDetails().isSignAuthNRequest())
|
|
|
.isEqualTo(registration.getProviderDetails().isSignAuthNRequest())
|
|
|
.isFalse();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- private RelyingPartyRegistration relyingPartyRegistration() {
|
|
|
- //remote IDP entity ID
|
|
|
- String idpEntityId = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php";
|
|
|
- //remote WebSSO Endpoint - Where to Send AuthNRequests to
|
|
|
- String webSsoEndpoint = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php";
|
|
|
- //local registration ID
|
|
|
- String registrationId = "simplesamlphp";
|
|
|
- //local entity ID - autogenerated based on URL
|
|
|
- String localEntityIdTemplate = "{baseUrl}/saml2/service-provider-metadata/{registrationId}";
|
|
|
- //local signing (and decryption key)
|
|
|
- Saml2X509Credential signingCredential = relyingPartySigningCredential();
|
|
|
- //IDP certificate for verification of incoming messages
|
|
|
- Saml2X509Credential idpVerificationCertificate = relyingPartyVerifyingCredential();
|
|
|
- String acsUrlTemplate = "{baseUrl}" + Saml2WebSsoAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI;
|
|
|
- return RelyingPartyRegistration.withRegistrationId(registrationId)
|
|
|
- .providerDetails(c -> {
|
|
|
- c.webSsoUrl(webSsoEndpoint);
|
|
|
- c.binding(Saml2MessageBinding.POST);
|
|
|
- c.signAuthNRequest(false);
|
|
|
- c.entityId(idpEntityId);
|
|
|
- })
|
|
|
- .credentials(c -> c.add(signingCredential))
|
|
|
- .credentials(c -> c.add(idpVerificationCertificate))
|
|
|
- .localEntityIdTemplate(localEntityIdTemplate)
|
|
|
- .assertionConsumerServiceUrlTemplate(acsUrlTemplate)
|
|
|
- .build();
|
|
|
- }
|
|
|
}
|