@@ -130,6 +130,35 @@ private RelyingPartyRegistration(String registrationId, String entityId, String
130
130
this .signingX509Credentials = Collections .unmodifiableList (new LinkedList <>(signingX509Credentials ));
131
131
}
132
132
133
+ /**
134
+ * Copy the properties in this {@link RelyingPartyRegistration} into a {@link Builder}
135
+ * @return a {@link Builder} based off of the properties in this
136
+ * {@link RelyingPartyRegistration}
137
+ * @since 6.1
138
+ */
139
+ public Builder mutate () {
140
+ AssertingPartyDetails party = this .assertingPartyDetails ;
141
+ return withRegistrationId (this .registrationId ).entityId (this .entityId )
142
+ .signingX509Credentials ((c ) -> c .addAll (this .signingX509Credentials ))
143
+ .decryptionX509Credentials ((c ) -> c .addAll (this .decryptionX509Credentials ))
144
+ .assertionConsumerServiceLocation (this .assertionConsumerServiceLocation )
145
+ .assertionConsumerServiceBinding (this .assertionConsumerServiceBinding )
146
+ .singleLogoutServiceLocation (this .singleLogoutServiceLocation )
147
+ .singleLogoutServiceResponseLocation (this .singleLogoutServiceResponseLocation )
148
+ .singleLogoutServiceBindings ((c ) -> c .addAll (this .singleLogoutServiceBindings ))
149
+ .nameIdFormat (this .nameIdFormat )
150
+ .assertingPartyDetails ((assertingParty ) -> assertingParty .entityId (party .getEntityId ())
151
+ .wantAuthnRequestsSigned (party .getWantAuthnRequestsSigned ())
152
+ .signingAlgorithms ((algorithms ) -> algorithms .addAll (party .getSigningAlgorithms ()))
153
+ .verificationX509Credentials ((c ) -> c .addAll (party .getVerificationX509Credentials ()))
154
+ .encryptionX509Credentials ((c ) -> c .addAll (party .getEncryptionX509Credentials ()))
155
+ .singleSignOnServiceLocation (party .getSingleSignOnServiceLocation ())
156
+ .singleSignOnServiceBinding (party .getSingleSignOnServiceBinding ())
157
+ .singleLogoutServiceLocation (party .getSingleLogoutServiceLocation ())
158
+ .singleLogoutServiceResponseLocation (party .getSingleLogoutServiceResponseLocation ())
159
+ .singleLogoutServiceBinding (party .getSingleLogoutServiceBinding ()));
160
+ }
161
+
133
162
/**
134
163
* Get the unique registration id for this RP/AP pair
135
164
* @return the unique registration id for this RP/AP pair
@@ -292,7 +321,7 @@ public AssertingPartyDetails getAssertingPartyDetails() {
292
321
*/
293
322
public static Builder withRegistrationId (String registrationId ) {
294
323
Assert .hasText (registrationId , "registrationId cannot be empty" );
295
- return new Builder (registrationId );
324
+ return new Builder (registrationId , new AssertingPartyDetails . Builder () );
296
325
}
297
326
298
327
public static Builder withAssertingPartyDetails (AssertingPartyDetails assertingPartyDetails ) {
@@ -315,7 +344,9 @@ public static Builder withAssertingPartyDetails(AssertingPartyDetails assertingP
315
344
* object
316
345
* @param registration the {@code RelyingPartyRegistration}
317
346
* @return {@code Builder} to create a {@code RelyingPartyRegistration} object
347
+ * @deprecated Use {@link #mutate()} instead
318
348
*/
349
+ @ Deprecated (forRemoval = true , since = "6.1" )
319
350
public static Builder withRelyingPartyRegistration (RelyingPartyRegistration registration ) {
320
351
Assert .notNull (registration , "registration cannot be null" );
321
352
return withRegistrationId (registration .getRegistrationId ()).entityId (registration .getEntityId ())
@@ -736,9 +767,9 @@ public AssertingPartyDetails build() {
736
767
737
768
}
738
769
739
- public static final class Builder {
770
+ public static class Builder {
740
771
741
- private Converter < AssertingPartyDetails , String > registrationId = AssertingPartyDetails :: getEntityId ;
772
+ private String registrationId ;
742
773
743
774
private String entityId = "{baseUrl}/saml2/service-provider-metadata/{registrationId}" ;
744
775
@@ -760,13 +791,9 @@ public static final class Builder {
760
791
761
792
private AssertingPartyDetails .Builder assertingPartyDetailsBuilder ;
762
793
763
- private Builder (String registrationId ) {
764
- this .registrationId = (party ) -> registrationId ;
765
- this .assertingPartyDetailsBuilder = new AssertingPartyDetails .Builder ();
766
- }
767
-
768
- Builder (AssertingPartyDetails .Builder builder ) {
769
- this .assertingPartyDetailsBuilder = builder ;
794
+ protected Builder (String registrationId , AssertingPartyDetails .Builder assertingPartyDetailsBuilder ) {
795
+ this .registrationId = registrationId ;
796
+ this .assertingPartyDetailsBuilder = assertingPartyDetailsBuilder ;
770
797
}
771
798
772
799
/**
@@ -775,7 +802,7 @@ private Builder(String registrationId) {
775
802
* @return this object
776
803
*/
777
804
public Builder registrationId (String id ) {
778
- this .registrationId = ( party ) -> id ;
805
+ this .registrationId = id ;
779
806
return this ;
780
807
}
781
808
@@ -974,11 +1001,11 @@ public RelyingPartyRegistration build() {
974
1001
}
975
1002
976
1003
AssertingPartyDetails party = this .assertingPartyDetailsBuilder .build ();
977
- String registrationId = this .registrationId . convert ( party );
978
- return new RelyingPartyRegistration ( registrationId , this .entityId , this .assertionConsumerServiceLocation ,
979
- this .assertionConsumerServiceBinding , this .singleLogoutServiceLocation ,
980
- this .singleLogoutServiceResponseLocation , this .singleLogoutServiceBindings , party ,
981
- this .nameIdFormat , this . decryptionX509Credentials , this . signingX509Credentials );
1004
+ return new RelyingPartyRegistration ( this .registrationId , this . entityId ,
1005
+ this .assertionConsumerServiceLocation , this .assertionConsumerServiceBinding ,
1006
+ this .singleLogoutServiceLocation , this .singleLogoutServiceResponseLocation ,
1007
+ this .singleLogoutServiceBindings , party , this .nameIdFormat , this . decryptionX509Credentials ,
1008
+ this .signingX509Credentials );
982
1009
}
983
1010
984
1011
}
0 commit comments