Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Define plain data constructor for OAuth2AuthenticationDetails #1001

Closed
wants to merge 1 commit into from
Closed
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 @@ -17,7 +17,6 @@
import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
* A holder of selected HTTP details related to an OAuth2 authentication request.
Expand Down Expand Up @@ -49,16 +48,19 @@ public class OAuth2AuthenticationDetails implements Serializable {
/**
* Records the access token value and remote address and will also set the session Id if a session already exists
* (it won't create one).
*
*
* @param request that the authentication request was received from
*/
public OAuth2AuthenticationDetails(HttpServletRequest request) {
this.tokenValue = (String) request.getAttribute(ACCESS_TOKEN_VALUE);
this.tokenType = (String) request.getAttribute(ACCESS_TOKEN_TYPE);
this.remoteAddress = request.getRemoteAddr();
this(request.getRemoteAddr(), request.getSession(false) != null ? request.getSession(false).getId() : null,
(String) request.getAttribute(ACCESS_TOKEN_TYPE), (String) request.getAttribute(ACCESS_TOKEN_VALUE));
}

HttpSession session = request.getSession(false);
this.sessionId = (session != null) ? session.getId() : null;
public OAuth2AuthenticationDetails(String remoteAddress, String sessionId, String tokenType, String tokenValue) {
Copy link
Contributor

@jgrandja jgrandja May 8, 2020

Choose a reason for hiding this comment

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

OAuth2AuthenticationDetails was intended to be used with HttpServletRequest, so I don't see a reason to provide this overloaded constructor.

this.remoteAddress = remoteAddress;
this.sessionId = sessionId;
this.tokenType = tokenType;
this.tokenValue = tokenValue;
StringBuilder builder = new StringBuilder();
if (remoteAddress!=null) {
builder.append("remoteAddress=").append(remoteAddress);
Expand Down