Commit e020ba38 authored by michael.simon's avatar michael.simon
Browse files

Make group and role session caching timeout configurable

parent f2b9e880
...@@ -83,6 +83,18 @@ public class AuthorizationBean implements Serializable { ...@@ -83,6 +83,18 @@ public class AuthorizationBean implements Serializable {
if (sessionManager.getUserId() == null) if (sessionManager.getUserId() == null)
return; return;
Long rolesTimeout;
if (appConfig.getConfigValue("AuthorizationBean_rolesTimeout") == null)
rolesTimeout = Long.parseLong(appConfig.getConfigValue("AuthorizationBean_rolesTimeout"));
else
rolesTimeout = 1 * 60 * 1000L;
Long groupsTimeout;
if (appConfig.getConfigValue("AuthorizationBean_groupsTimeout") == null)
groupsTimeout = Long.parseLong(appConfig.getConfigValue("AuthorizationBean_groupsTimeout"));
else
groupsTimeout = 1 * 60 * 1000L;
long start, end; long start, end;
start = System.currentTimeMillis(); start = System.currentTimeMillis();
...@@ -90,8 +102,8 @@ public class AuthorizationBean implements Serializable { ...@@ -90,8 +102,8 @@ public class AuthorizationBean implements Serializable {
end = System.currentTimeMillis(); end = System.currentTimeMillis();
logger.debug("user find by id with store loading took {} ms", (end-start)); logger.debug("user find by id with store loading took {} ms", (end-start));
if (sessionManager.getRoleSetCreated() == null || if (sessionManager.getGroupSetCreated() == null ||
(System.currentTimeMillis() - sessionManager.getRoleSetCreated()) > 5 * 60 * 1000L) { (System.currentTimeMillis() - sessionManager.getGroupSetCreated()) > groupsTimeout) {
start = System.currentTimeMillis(); start = System.currentTimeMillis();
Set<GroupEntity> groupList = groupService.findByUserWithParents(user); Set<GroupEntity> groupList = groupService.findByUserWithParents(user);
...@@ -101,6 +113,8 @@ public class AuthorizationBean implements Serializable { ...@@ -101,6 +113,8 @@ public class AuthorizationBean implements Serializable {
sessionManager.getGroupList().add(g.getId()); sessionManager.getGroupList().add(g.getId());
} }
sessionManager.setGroupSetCreated(System.currentTimeMillis());
end = System.currentTimeMillis(); end = System.currentTimeMillis();
logger.debug("groups loading took {} ms", (end-start)); logger.debug("groups loading took {} ms", (end-start));
} }
...@@ -145,7 +159,7 @@ public class AuthorizationBean implements Serializable { ...@@ -145,7 +159,7 @@ public class AuthorizationBean implements Serializable {
unregisteredServiceList.removeAll(serviceToRemove); unregisteredServiceList.removeAll(serviceToRemove);
if (sessionManager.getRoleSetCreated() == null || if (sessionManager.getRoleSetCreated() == null ||
(System.currentTimeMillis() - sessionManager.getRoleSetCreated()) > 5 * 60 * 1000L) { (System.currentTimeMillis() - sessionManager.getRoleSetCreated()) > rolesTimeout) {
start = System.currentTimeMillis(); start = System.currentTimeMillis();
List<RoleEntity> roleList = roleService.findByUser(user); List<RoleEntity> roleList = roleService.findByUser(user);
......
...@@ -50,6 +50,7 @@ public class SessionManager implements Serializable { ...@@ -50,6 +50,7 @@ public class SessionManager implements Serializable {
private List<Long> groupList; private List<Long> groupList;
private String groupString; private String groupString;
private Long groupSetCreated;
private String theme; private String theme;
...@@ -215,4 +216,12 @@ public class SessionManager implements Serializable { ...@@ -215,4 +216,12 @@ public class SessionManager implements Serializable {
public void setGroupString(String groupString) { public void setGroupString(String groupString) {
this.groupString = groupString; this.groupString = groupString;
} }
public Long getGroupSetCreated() {
return groupSetCreated;
}
public void setGroupSetCreated(Long groupSetCreated) {
this.groupSetCreated = groupSetCreated;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment