Skip to content

Commit e50415d

Browse files
ngocnhan-tran1996jzheaux
authored andcommitted
Make RelyingPartyRegistration Serializable
Closes gh-16286
1 parent fbebd03 commit e50415d

7 files changed

+24
-5
lines changed

config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@
173173
import org.springframework.security.oauth2.server.resource.introspection.OAuth2IntrospectionException;
174174
import org.springframework.security.saml2.Saml2Exception;
175175
import org.springframework.security.saml2.core.Saml2Error;
176+
import org.springframework.security.saml2.core.Saml2X509Credential;
177+
import org.springframework.security.saml2.credentials.TestSaml2X509Credentials;
176178
import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
177179
import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
178180
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationException;
@@ -181,6 +183,9 @@
181183
import org.springframework.security.saml2.provider.service.authentication.TestSaml2Authentications;
182184
import org.springframework.security.saml2.provider.service.authentication.TestSaml2PostAuthenticationRequests;
183185
import org.springframework.security.saml2.provider.service.authentication.TestSaml2RedirectAuthenticationRequests;
186+
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
187+
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails;
188+
import org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations;
184189
import org.springframework.security.web.PortResolverImpl;
185190
import org.springframework.security.web.authentication.WebAuthenticationDetails;
186191
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
@@ -490,6 +495,11 @@ class SpringSecurityCoreVersionSerializableTests {
490495
(r) -> TestSaml2PostAuthenticationRequests.create());
491496
generatorByClassName.put(Saml2RedirectAuthenticationRequest.class,
492497
(r) -> TestSaml2RedirectAuthenticationRequests.create());
498+
generatorByClassName.put(Saml2X509Credential.class,
499+
(r) -> TestSaml2X509Credentials.relyingPartyVerifyingCredential());
500+
generatorByClassName.put(AssertingPartyDetails.class,
501+
(r) -> TestRelyingPartyRegistrations.full().build().getAssertingPartyMetadata());
502+
generatorByClassName.put(RelyingPartyRegistration.class, (r) -> TestRelyingPartyRegistrations.full().build());
493503

494504
// web
495505
generatorByClassName.put(AnonymousAuthenticationToken.class, (r) -> {

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/core/Saml2X509Credential.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.saml2.core;
1818

19+
import java.io.Serializable;
1920
import java.security.PrivateKey;
2021
import java.security.cert.X509Certificate;
2122
import java.util.Arrays;
@@ -35,7 +36,9 @@
3536
* @author Josh Cummings
3637
* @since 5.4
3738
*/
38-
public final class Saml2X509Credential {
39+
public final class Saml2X509Credential implements Serializable {
40+
41+
private static final long serialVersionUID = -1015853414272603517L;
3942

4043
private final PrivateKey privateKey;
4144

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/registration/AssertingPartyMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.saml2.provider.service.registration;
1818

19+
import java.io.Serializable;
1920
import java.util.Collection;
2021
import java.util.List;
2122
import java.util.function.Consumer;
@@ -28,7 +29,7 @@
2829
* @author Josh Cummings
2930
* @since 6.4
3031
*/
31-
public interface AssertingPartyMetadata {
32+
public interface AssertingPartyMetadata extends Serializable {
3233

3334
/**
3435
* Get the asserting party's <a href=

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/registration/RelyingPartyRegistration.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.saml2.provider.service.registration;
1818

19+
import java.io.Serializable;
1920
import java.util.ArrayList;
2021
import java.util.Collection;
2122
import java.util.Collections;
@@ -66,7 +67,9 @@
6667
* @author Josh Cummings
6768
* @since 5.2
6869
*/
69-
public class RelyingPartyRegistration {
70+
public class RelyingPartyRegistration implements Serializable {
71+
72+
private static final long serialVersionUID = -2718908121120942813L;
7073

7174
private final String registrationId;
7275

@@ -456,6 +459,8 @@ public static Builder withRelyingPartyRegistration(RelyingPartyRegistration regi
456459
*/
457460
public static class AssertingPartyDetails implements AssertingPartyMetadata {
458461

462+
private static final long serialVersionUID = 8728930758311995475L;
463+
459464
private final String entityId;
460465

461466
private final boolean wantAuthnRequestsSigned;

0 commit comments

Comments
 (0)