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

Gh 12472 #12638

Closed
wants to merge 1 commit into from
Closed

Gh 12472 #12638

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
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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 Down Expand Up @@ -60,7 +60,7 @@ public final class Saml2LogoutRequest implements Serializable {

private final String relyingPartyRegistrationId;

private Function<Map<String, String>, String> encoder;
private transient Function<Map<String, String>, String> encoder;

private Saml2LogoutRequest(String location, Saml2MessageBinding binding, Map<String, String> parameters, String id,
String relyingPartyRegistrationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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,11 @@

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

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

@Test
void serializeAndDeserializeSaml2LogoutRequest() throws IOException, ClassNotFoundException {
Saml2LogoutRequest requestToSerialize = createLogoutRequest().relayState("state-serialized").build();
byte[] data;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream)) {
objectOutputStream.writeObject(requestToSerialize);
data = outputStream.toByteArray();
}

try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
ObjectInputStream objectInputStream = new ObjectInputStream(inputStream)) {
Saml2LogoutRequest deserializedRequest = (Saml2LogoutRequest) objectInputStream.readObject();
assertThat(requestToSerialize.getRelayState()).isEqualTo(deserializedRequest.getRelayState());
}
}

@Test
public void loadLogoutRequestWhenSavedAndStateParameterNullThenReturnNull() {
MockHttpServletRequest request = new MockHttpServletRequest();
Expand Down