Skip to content

Commit

Permalink
Issue #6205 - Fix serialization issues in OpenIdAuthenticator
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts authored and sbordet committed May 12, 2021
1 parent 2e7f5eb commit 9cb9343
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,22 +526,30 @@ private Map<String, UriRedirectInfo> ensureCsrfMap(HttpSession session)
Map<String, UriRedirectInfo> csrfMap = (Map<String, UriRedirectInfo>)session.getAttribute(CSRF_MAP);
if (csrfMap == null)
{
// Create a custom Map so we can only have a limited number of request URIs saved.
csrfMap = new LinkedHashMap<String, UriRedirectInfo>()
{
private static final int MAX_SIZE = 64;

@Override
protected boolean removeEldestEntry(Map.Entry<String, UriRedirectInfo> eldest)
{
return size() > MAX_SIZE;
}
};
csrfMap = new MRUMap(64);
session.setAttribute(CSRF_MAP, csrfMap);
}
return csrfMap;
}

private static class MRUMap extends LinkedHashMap<String, UriRedirectInfo>
{
private static final long serialVersionUID = 5375723072014233L;

private final int _size;

private MRUMap(int size)
{
_size = size;
}

@Override
protected boolean removeEldestEntry(Map.Entry<String, UriRedirectInfo> eldest)
{
return size() > _size;
}
}

private static class UriRedirectInfo implements Serializable
{
private static final long serialVersionUID = 139567755844461433L;
Expand Down

0 comments on commit 9cb9343

Please sign in to comment.