Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Saml2AuthenticationToken Serializable #16287

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
import org.springframework.security.oauth2.server.resource.introspection.OAuth2IntrospectionAuthenticatedPrincipal;
import org.springframework.security.saml2.Saml2Exception;
import org.springframework.security.saml2.core.Saml2Error;
import org.springframework.security.saml2.core.Saml2X509Credential;
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;
Expand All @@ -126,6 +128,9 @@
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;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails;
import org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException;
Expand Down Expand Up @@ -322,6 +327,11 @@ class SpringSecurityCoreVersionSerializableTests {
(r) -> TestSaml2PostAuthenticationRequests.create());
generatorByClassName.put(Saml2RedirectAuthenticationRequest.class,
(r) -> TestSaml2RedirectAuthenticationRequests.create());
generatorByClassName.put(Saml2X509Credential.class,
(r) -> TestSaml2X509Credentials.relyingPartyVerifyingCredential());
generatorByClassName.put(AssertingPartyDetails.class,
(r) -> TestRelyingPartyRegistrations.full().build().getAssertingPartyMetadata());
generatorByClassName.put(RelyingPartyRegistration.class, (r) -> TestRelyingPartyRegistrations.full().build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the serializeCurrentVersionClasses test so that the appropriate .serialized file gets created. You can see #16276 for more details.


// web
generatorByClassName.put(AnonymousAuthenticationToken.class, (r) -> {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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.
Expand All @@ -16,6 +16,7 @@

package org.springframework.security.saml2.core;

import java.io.Serializable;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Arrays;
Expand All @@ -35,7 +36,9 @@
* @author Josh Cummings
* @since 5.4
*/
public final class Saml2X509Credential {
public final class Saml2X509Credential implements Serializable {

private static final long serialVersionUID = -1015853414272603517L;

private final PrivateKey privateKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
Expand All @@ -28,7 +29,7 @@
* @author Josh Cummings
* @since 6.4
*/
public interface AssertingPartyMetadata {
public interface AssertingPartyMetadata extends Serializable {
jzheaux marked this conversation as resolved.
Show resolved Hide resolved

/**
* Get the asserting party's <a href=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
Expand All @@ -16,6 +16,7 @@

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

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -66,7 +67,9 @@
* @author Josh Cummings
* @since 5.2
*/
public class RelyingPartyRegistration {
public class RelyingPartyRegistration implements Serializable {

private static final long serialVersionUID = -2718908121120942813L;

private final String registrationId;

Expand Down Expand Up @@ -456,6 +459,8 @@ public static Builder withRelyingPartyRegistration(RelyingPartyRegistration regi
*/
public static class AssertingPartyDetails implements AssertingPartyMetadata {

private static final long serialVersionUID = 8728930758311995475L;

private final String entityId;

private final boolean wantAuthnRequestsSigned;
Expand Down
Loading