Make Saml2AuthenticationToken Serializable

Issue gh-16286
This commit is contained in:
Josh Cummings 2025-01-30 18:05:17 -07:00
parent bcc4b415b3
commit 5ff87128b1
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
3 changed files with 14 additions and 0 deletions

View File

@ -178,8 +178,10 @@ import org.springframework.security.saml2.credentials.TestSaml2X509Credentials;
import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationException;
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken;
import org.springframework.security.saml2.provider.service.authentication.Saml2PostAuthenticationRequest;
import org.springframework.security.saml2.provider.service.authentication.Saml2RedirectAuthenticationRequest;
import org.springframework.security.saml2.provider.service.authentication.TestSaml2AuthenticationTokens;
import org.springframework.security.saml2.provider.service.authentication.TestSaml2Authentications;
import org.springframework.security.saml2.provider.service.authentication.TestSaml2PostAuthenticationRequests;
import org.springframework.security.saml2.provider.service.authentication.TestSaml2RedirectAuthenticationRequests;
@ -500,6 +502,11 @@ class SpringSecurityCoreVersionSerializableTests {
generatorByClassName.put(AssertingPartyDetails.class,
(r) -> TestRelyingPartyRegistrations.full().build().getAssertingPartyMetadata());
generatorByClassName.put(RelyingPartyRegistration.class, (r) -> TestRelyingPartyRegistrations.full().build());
generatorByClassName.put(Saml2AuthenticationToken.class, (r) -> {
Saml2AuthenticationToken token = TestSaml2AuthenticationTokens.tokenRequested();
token.setDetails(details);
return token;
});
// web
generatorByClassName.put(AnonymousAuthenticationToken.class, (r) -> {

View File

@ -35,4 +35,11 @@ public final class TestSaml2AuthenticationTokens {
return new Saml2AuthenticationToken(relyingPartyRegistration, "saml2-xml-response-object");
}
public static Saml2AuthenticationToken tokenRequested() {
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.relyingPartyRegistration()
.build();
return new Saml2AuthenticationToken(relyingPartyRegistration, "saml2-xml-response-object",
TestSaml2PostAuthenticationRequests.create());
}
}