|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2002-2022 the original author or authors.
|
|
|
+ * Copyright 2002-2023 the original author or authors.
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -26,6 +26,7 @@ import java.util.function.Consumer;
|
|
|
|
|
|
import org.opensaml.xmlsec.signature.support.SignatureConstants;
|
|
|
|
|
|
+import org.springframework.core.convert.converter.Converter;
|
|
|
import org.springframework.security.saml2.core.Saml2X509Credential;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -737,7 +738,7 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
public static final class Builder {
|
|
|
|
|
|
- private String registrationId;
|
|
|
+ private Converter<AssertingPartyDetails, String> registrationId = AssertingPartyDetails::getEntityId;
|
|
|
|
|
|
private String entityId = "{baseUrl}/saml2/service-provider-metadata/{registrationId}";
|
|
|
|
|
@@ -757,10 +758,15 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
private String nameIdFormat = null;
|
|
|
|
|
|
- private AssertingPartyDetails.Builder assertingPartyDetailsBuilder = new AssertingPartyDetails.Builder();
|
|
|
+ private AssertingPartyDetails.Builder assertingPartyDetailsBuilder;
|
|
|
|
|
|
private Builder(String registrationId) {
|
|
|
- this.registrationId = registrationId;
|
|
|
+ this.registrationId = (party) -> registrationId;
|
|
|
+ this.assertingPartyDetailsBuilder = new AssertingPartyDetails.Builder();
|
|
|
+ }
|
|
|
+
|
|
|
+ Builder(AssertingPartyDetails.Builder builder) {
|
|
|
+ this.assertingPartyDetailsBuilder = builder;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -769,7 +775,7 @@ public final class RelyingPartyRegistration {
|
|
|
* @return this object
|
|
|
*/
|
|
|
public Builder registrationId(String id) {
|
|
|
- this.registrationId = id;
|
|
|
+ this.registrationId = (party) -> id;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
@@ -967,11 +973,12 @@ public final class RelyingPartyRegistration {
|
|
|
this.singleLogoutServiceBindings.add(Saml2MessageBinding.POST);
|
|
|
}
|
|
|
|
|
|
- return new RelyingPartyRegistration(this.registrationId, this.entityId,
|
|
|
- this.assertionConsumerServiceLocation, this.assertionConsumerServiceBinding,
|
|
|
- this.singleLogoutServiceLocation, this.singleLogoutServiceResponseLocation,
|
|
|
- this.singleLogoutServiceBindings, this.assertingPartyDetailsBuilder.build(), this.nameIdFormat,
|
|
|
- this.decryptionX509Credentials, this.signingX509Credentials);
|
|
|
+ AssertingPartyDetails party = this.assertingPartyDetailsBuilder.build();
|
|
|
+ String registrationId = this.registrationId.convert(party);
|
|
|
+ return new RelyingPartyRegistration(registrationId, this.entityId, this.assertionConsumerServiceLocation,
|
|
|
+ this.assertionConsumerServiceBinding, this.singleLogoutServiceLocation,
|
|
|
+ this.singleLogoutServiceResponseLocation, this.singleLogoutServiceBindings, party,
|
|
|
+ this.nameIdFormat, this.decryptionX509Credentials, this.signingX509Credentials);
|
|
|
}
|
|
|
|
|
|
}
|