mirror of
https://github.com/bmlong137/alfresco-keycloak.git
synced 2025-05-26 21:44:41 +00:00
Don't override old user groups if refresh fails
This commit is contained in:
parent
6298c898e2
commit
6e6e21dbf8
@ -154,8 +154,16 @@ public class UserGroupsLoadFilter implements DependencyInjectedFilter, Initializ
|
|||||||
if (userGroupsCSVList == null
|
if (userGroupsCSVList == null
|
||||||
|| (lastLoaded != null && lastLoaded.getTime() + cachedUserGroupsTimeout < System.currentTimeMillis()))
|
|| (lastLoaded != null && lastLoaded.getTime() + cachedUserGroupsTimeout < System.currentTimeMillis()))
|
||||||
{
|
{
|
||||||
session.setAttribute(SlingshotLoginController.SESSION_ATTRIBUTE_KEY_USER_GROUPS,
|
final String reloadedUserGroupsCSVList = this.loadUserGroupsCSVList((HttpServletRequest) request, session, userId);
|
||||||
this.loadUserGroupsCSVList((HttpServletRequest) request, session, userId));
|
if (reloadedUserGroupsCSVList != null)
|
||||||
|
{
|
||||||
|
session.setAttribute(SlingshotLoginController.SESSION_ATTRIBUTE_KEY_USER_GROUPS, reloadedUserGroupsCSVList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.debug(
|
||||||
|
"User groups session attribute cannot be updated after failure to load - will retry after next cache timeout");
|
||||||
|
}
|
||||||
session.setAttribute(SESSION_ATTRIBUTE_KEY_USER_GROUPS_LAST_LOADED, new Date());
|
session.setAttribute(SESSION_ATTRIBUTE_KEY_USER_GROUPS_LAST_LOADED, new Date());
|
||||||
}
|
}
|
||||||
else if (lastLoaded == null)
|
else if (lastLoaded == null)
|
||||||
@ -245,17 +253,23 @@ public class UserGroupsLoadFilter implements DependencyInjectedFilter, Initializ
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO Specific handling for expectable error codes (401 / 302)
|
if (res.getStatus().getCode() == 401)
|
||||||
LOGGER.warn("Failed to load user groups for {} with backend call resulting in HTTP response with status {} {}",
|
{
|
||||||
userId,
|
LOGGER.debug("Failed to load user groups for {} with backend call as authentication was not / no longer active",
|
||||||
res.getStatus().getCode(), res.getStatus().getMessage());
|
userId);
|
||||||
userGroupsCSVList = "";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to load user groups for {} with backend call resulting in HTTP response with status {} {}", userId,
|
||||||
|
res.getStatus().getCode(), res.getStatus().getMessage());
|
||||||
|
}
|
||||||
|
userGroupsCSVList = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (final ConnectorServiceException | ParseException ex)
|
catch (final ConnectorServiceException | ParseException ex)
|
||||||
{
|
{
|
||||||
LOGGER.error("Failed to load user groups for {}", userId, ex);
|
LOGGER.error("Failed to load user groups for {}", userId, ex);
|
||||||
userGroupsCSVList = "";
|
userGroupsCSVList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return userGroupsCSVList;
|
return userGroupsCSVList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user