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 <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed May 12, 2021
1 parent df68a12 commit ffcc7ae
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -521,22 +521,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<>()
{
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> implements Serializable
{
private static final long serialVersionUID = 5375723072014233L;

private final int _size;

public 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 ffcc7ae

Please sign in to comment.