Skip to content

Commit acaf9ce

Browse files
Merge branch '6.1.x' into 6.2.x
Closes gh-14405
2 parents cb56d1c + d032b23 commit acaf9ce

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchange.java

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

1717
package org.springframework.security.oauth2.core.endpoint;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
21+
22+
import org.springframework.security.core.SpringSecurityCoreVersion;
1923
import org.springframework.util.Assert;
2024

2125
/**
@@ -27,7 +31,10 @@
2731
* @see OAuth2AuthorizationRequest
2832
* @see OAuth2AuthorizationResponse
2933
*/
30-
public final class OAuth2AuthorizationExchange {
34+
public final class OAuth2AuthorizationExchange implements Serializable {
35+
36+
@Serial
37+
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
3138

3239
private final OAuth2AuthorizationRequest authorizationRequest;
3340

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationResponse.java

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

1717
package org.springframework.security.oauth2.core.endpoint;
1818

19+
import java.io.Serial;
20+
import java.io.Serializable;
21+
22+
import org.springframework.security.core.SpringSecurityCoreVersion;
1923
import org.springframework.security.oauth2.core.OAuth2Error;
2024
import org.springframework.util.Assert;
2125
import org.springframework.util.StringUtils;
@@ -31,7 +35,10 @@
3135
* "https://tools.ietf.org/html/rfc6749#section-4.1.2">Section 4.1.2 Authorization
3236
* Response</a>
3337
*/
34-
public final class OAuth2AuthorizationResponse {
38+
public final class OAuth2AuthorizationResponse implements Serializable {
39+
40+
@Serial
41+
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
3542

3643
private String redirectUri;
3744

oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchangeTests.java

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

1717
package org.springframework.security.oauth2.core.endpoint;
1818

19+
import java.io.ByteArrayOutputStream;
20+
import java.io.IOException;
21+
import java.io.ObjectOutputStream;
22+
1923
import org.junit.jupiter.api.Test;
2024

2125
import static org.assertj.core.api.Assertions.assertThat;
@@ -50,4 +54,15 @@ public void constructorWhenRequiredArgsProvidedThenCreated() {
5054
assertThat(authorizationExchange.getAuthorizationResponse()).isEqualTo(authorizationResponse);
5155
}
5256

57+
@Test
58+
void oauth2AuthorizationExchangeShouldBeSerializable() throws IOException {
59+
OAuth2AuthorizationExchange exchange = TestOAuth2AuthorizationExchanges.success();
60+
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
61+
ObjectOutputStream objectOutputStream = new ObjectOutputStream(baos)) {
62+
objectOutputStream.writeObject(exchange);
63+
objectOutputStream.flush();
64+
assertThat(baos.size()).isNotZero();
65+
}
66+
}
67+
5368
}

0 commit comments

Comments
 (0)