Skip to content

Commit

Permalink
SECOAUTH-362: add toSTring() to auth details
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Nov 22, 2012
1 parent 421338e commit ea2203d
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class OAuth2AuthenticationDetails implements Serializable {

private final String tokenValue;

private final String display;

/**
* 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).
Expand All @@ -49,6 +51,23 @@ public OAuth2AuthenticationDetails(HttpServletRequest request) {

HttpSession session = request.getSession(false);
this.sessionId = (session != null) ? session.getId() : null;
StringBuilder builder = new StringBuilder();
if (remoteAddress!=null) {
builder.append("remoteAddress=").append(remoteAddress);
}
if (builder.length()>1) {
builder.append(", ");
}
if (sessionId!=null) {
builder.append("sessionId=<SESSION>");
}
if (builder.length()>1) {
builder.append(", ");
}
if (tokenValue!=null) {
builder.append("tokenValue=<TOKEN>");
}
this.display = builder.toString();
}

/**
Expand Down Expand Up @@ -78,4 +97,9 @@ public String getSessionId() {
return sessionId;
}

@Override
public String toString() {
return display;
}

}

0 comments on commit ea2203d

Please sign in to comment.