Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
e020ba38
Commit
e020ba38
authored
Aug 03, 2015
by
michael.simon
Browse files
Make group and role session caching timeout configurable
parent
f2b9e880
Changes
2
Hide whitespace changes
Inline
Side-by-side
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/AuthorizationBean.java
View file @
e020ba38
...
...
@@ -83,6 +83,18 @@ public class AuthorizationBean implements Serializable {
if
(
sessionManager
.
getUserId
()
==
null
)
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
;
start
=
System
.
currentTimeMillis
();
...
...
@@ -90,8 +102,8 @@ public class AuthorizationBean implements Serializable {
end
=
System
.
currentTimeMillis
();
logger
.
debug
(
"user find by id with store loading took {} ms"
,
(
end
-
start
));
if
(
sessionManager
.
get
Role
SetCreated
()
==
null
||
(
System
.
currentTimeMillis
()
-
sessionManager
.
get
Role
SetCreated
())
>
5
*
60
*
1000L
)
{
if
(
sessionManager
.
get
Group
SetCreated
()
==
null
||
(
System
.
currentTimeMillis
()
-
sessionManager
.
get
Group
SetCreated
())
>
groupsTimeout
)
{
start
=
System
.
currentTimeMillis
();
Set
<
GroupEntity
>
groupList
=
groupService
.
findByUserWithParents
(
user
);
...
...
@@ -101,6 +113,8 @@ public class AuthorizationBean implements Serializable {
sessionManager
.
getGroupList
().
add
(
g
.
getId
());
}
sessionManager
.
setGroupSetCreated
(
System
.
currentTimeMillis
());
end
=
System
.
currentTimeMillis
();
logger
.
debug
(
"groups loading took {} ms"
,
(
end
-
start
));
}
...
...
@@ -145,7 +159,7 @@ public class AuthorizationBean implements Serializable {
unregisteredServiceList
.
removeAll
(
serviceToRemove
);
if
(
sessionManager
.
getRoleSetCreated
()
==
null
||
(
System
.
currentTimeMillis
()
-
sessionManager
.
getRoleSetCreated
())
>
5
*
60
*
1000L
)
{
(
System
.
currentTimeMillis
()
-
sessionManager
.
getRoleSetCreated
())
>
rolesTimeout
)
{
start
=
System
.
currentTimeMillis
();
List
<
RoleEntity
>
roleList
=
roleService
.
findByUser
(
user
);
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/util/SessionManager.java
View file @
e020ba38
...
...
@@ -50,6 +50,7 @@ public class SessionManager implements Serializable {
private
List
<
Long
>
groupList
;
private
String
groupString
;
private
Long
groupSetCreated
;
private
String
theme
;
...
...
@@ -215,4 +216,12 @@ public class SessionManager implements Serializable {
public
void
setGroupString
(
String
groupString
)
{
this
.
groupString
=
groupString
;
}
public
Long
getGroupSetCreated
()
{
return
groupSetCreated
;
}
public
void
setGroupSetCreated
(
Long
groupSetCreated
)
{
this
.
groupSetCreated
=
groupSetCreated
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment