Skip to content

Commit 4b5bacf

Browse files
committed
Make Saml2AuthenticationToken Serializable
Issue gh-16286
1 parent e50415d commit 4b5bacf

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@
178178
import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
179179
import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
180180
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationException;
181+
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken;
181182
import org.springframework.security.saml2.provider.service.authentication.Saml2PostAuthenticationRequest;
182183
import org.springframework.security.saml2.provider.service.authentication.Saml2RedirectAuthenticationRequest;
184+
import org.springframework.security.saml2.provider.service.authentication.TestSaml2AuthenticationTokens;
183185
import org.springframework.security.saml2.provider.service.authentication.TestSaml2Authentications;
184186
import org.springframework.security.saml2.provider.service.authentication.TestSaml2PostAuthenticationRequests;
185187
import org.springframework.security.saml2.provider.service.authentication.TestSaml2RedirectAuthenticationRequests;
@@ -500,6 +502,11 @@ class SpringSecurityCoreVersionSerializableTests {
500502
generatorByClassName.put(AssertingPartyDetails.class,
501503
(r) -> TestRelyingPartyRegistrations.full().build().getAssertingPartyMetadata());
502504
generatorByClassName.put(RelyingPartyRegistration.class, (r) -> TestRelyingPartyRegistrations.full().build());
505+
generatorByClassName.put(Saml2AuthenticationToken.class, (r) -> {
506+
Saml2AuthenticationToken token = TestSaml2AuthenticationTokens.tokenRequested();
507+
token.setDetails(details);
508+
return token;
509+
});
503510

504511
// web
505512
generatorByClassName.put(AnonymousAuthenticationToken.class, (r) -> {

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/TestSaml2AuthenticationTokens.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@ public static Saml2AuthenticationToken token() {
3535
return new Saml2AuthenticationToken(relyingPartyRegistration, "saml2-xml-response-object");
3636
}
3737

38+
public static Saml2AuthenticationToken tokenRequested() {
39+
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.relyingPartyRegistration()
40+
.build();
41+
return new Saml2AuthenticationToken(relyingPartyRegistration, "saml2-xml-response-object",
42+
TestSaml2PostAuthenticationRequests.create());
43+
}
44+
3845
}

0 commit comments

Comments
 (0)