Skip to content

Commit 79887fa

Browse files
dkodippilyjzheaux
authored andcommitted
Closes gh-12472
1 parent 35cf52d commit 79887fa

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/logout/Saml2LogoutRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -60,7 +60,7 @@ public final class Saml2LogoutRequest implements Serializable {
6060

6161
private final String relyingPartyRegistrationId;
6262

63-
private Function<Map<String, String>, String> encoder;
63+
private transient Function<Map<String, String>, String> encoder;
6464

6565
private Saml2LogoutRequest(String location, Saml2MessageBinding binding, Map<String, String> parameters, String id,
6666
String relyingPartyRegistrationId) {

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/web/authentication/logout/HttpSessionLogoutRequestRepositoryTests.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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,11 @@
1616

1717
package org.springframework.security.saml2.provider.service.web.authentication.logout;
1818

19+
import java.io.ByteArrayInputStream;
20+
import java.io.ByteArrayOutputStream;
21+
import java.io.IOException;
22+
import java.io.ObjectInputStream;
23+
import java.io.ObjectOutputStream;
1924
import java.util.HashMap;
2025
import java.util.Map;
2126

@@ -77,6 +82,23 @@ public void loadLogoutRequestWhenMultipleSavedThenReplacesLogoutRequest() {
7782
assertThat(this.logoutRequestRepository.loadLogoutRequest(request)).isEqualTo(two);
7883
}
7984

85+
@Test
86+
void serializeAndDeserializeSaml2LogoutRequest() throws IOException, ClassNotFoundException {
87+
Saml2LogoutRequest requestToSerialize = createLogoutRequest().relayState("state-serialized").build();
88+
byte[] data;
89+
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
90+
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream)) {
91+
objectOutputStream.writeObject(requestToSerialize);
92+
data = outputStream.toByteArray();
93+
}
94+
95+
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
96+
ObjectInputStream objectInputStream = new ObjectInputStream(inputStream)) {
97+
Saml2LogoutRequest deserializedRequest = (Saml2LogoutRequest) objectInputStream.readObject();
98+
assertThat(requestToSerialize.getRelayState()).isEqualTo(deserializedRequest.getRelayState());
99+
}
100+
}
101+
80102
@Test
81103
public void loadLogoutRequestWhenSavedAndStateParameterNullThenReturnNull() {
82104
MockHttpServletRequest request = new MockHttpServletRequest();

0 commit comments

Comments
 (0)