|
|
Re: Kill/Shutdown the UIThread from a background thread [message #1768671 is a reply to message #1768549] |
Fri, 21 July 2017 08:27 |
MIchael P Messages: 3 Registered: March 2017 |
Junior Member |
|
|
As I understand an attribute is added to the HttpSession, which acts as a callback when removed from the session. I'm not sure if there is a standard on how the HttpSession must behave, but looking at the Shiro session the attribute is not removed before logging out or invalidating the session. This leads to an invalid HttpSession and a UIThread which is waiting.
As a workaround, I try to call the valueUnbound method of the HttpSessionBindingListener when logging out of the Shiro session.
This is done with the onLogout method of the realm and looks like this
@Override
public void onLogout(PrincipalCollection principals) {
super.onLogout(principals);
Collection<Object> list = SecurityUtils.getSubject().getSession(false).getAttributeKeys();
for (Iterator<Object> it = list.iterator(); it.hasNext();) {
Object key = it.next();
if (key instanceof String) {
String skey = (String) key;
if (skey.contains("UISession")) {
Object callback = SecurityUtils.getSubject().getSession(false).getAttribute(key);
if (callback instanceof HttpSessionBindingListener) {
HttpSessionBindingListener listener = (HttpSessionBindingListener) callback;
listener.valueUnbound(null);
}
}
}
}
}
I hope I don't mess something up with this approach, but I think it should behave the same as calling shutdown on UISessionImpl.
[Updated on: Fri, 21 July 2017 08:34] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03257 seconds