Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » AccessControlService execLoadPermissions() called a lot
AccessControlService execLoadPermissions() called a lot [message #1709595] Tue, 29 September 2015 13:12 Go to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
So we recently noticed that execLoadPermissions() is called like... every few seconds for each user (still on luna 4.0.100), is this normal? Should this method be "fast" or did we trigger some strange state and this behaviour is not really normal? I would like to know this so I know where to start troubleshooting (in first case our method, in second the session handling).
Re: AccessControlService execLoadPermissions() called a lot [message #1709655 is a reply to message #1709595] Wed, 30 September 2015 06:40 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I cannot reproduce what you are describing in in a simple Application.

When this code is executed:
if (!ACCESS.check(new ReadCompanyPermission())) {
  throw new VetoException(TEXTS.get("AuthorizationFailed"));
}

My call stack looks like this:
AccessControlService(AbstractAccessControlService).getPermissions() line: 196
AccessControlService(AbstractAccessControlService).checkPermission(Permission) line: 140
ACCESS.check(Permission) line: 33
CompanyService.load(CompanyFormData) line: 37


And in the AbstractAccessControlService.getPermissions() method, the m_accessControlStore returns a permission set. execLoadPermissions is not called again.

I am not sure why you have observed this behavior. Can you provide more information?

[Updated on: Wed, 30 September 2015 06:40]

Report message to a moderator

Re: AccessControlService execLoadPermissions() called a lot [message #1709676 is a reply to message #1709655] Wed, 30 September 2015 09:31 Go to previous messageGo to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
Yes, I definitely need to figure out what is going on here, because we update user login timestamp in this method and now it is updated constantly. One way to "fix" this would be if there is another function I can use to handle that. Still this would be a workaround and I am probably correct to assume this method should be called once after user logs in?
Re: AccessControlService execLoadPermissions() called a lot [message #1709678 is a reply to message #1709676] Wed, 30 September 2015 09:54 Go to previous messageGo to next message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
The problem is that we are calling clearCache() within the execLoadPermissions() function. What we wanted to achieve was to always reload permissions on log-in. What we got is that permissions are probably loaded for each request or something like that.

Things are fine as soon as I remove that clearCache() call. The problem is that we actually need to be able to reload permissions in case they have changed. How should we handle that?

And thanks for the quick response Smile

edit: To clarify - clearCache() works as long as it is empty... and starts making problems after the second user logs in and the cache is cleared. I will try to reproduce this in a simple project.

[Updated on: Wed, 30 September 2015 11:33]

Report message to a moderator

Re: AccessControlService execLoadPermissions() called a lot [message #1709740 is a reply to message #1709678] Wed, 30 September 2015 16:01 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Calling clearCache() inside execLoadPermissions() doesn't make sense to me.

It should be called from somewhere else in the server like this:
SERVICES.getService(IAccessControlService.class).clearCache();


Let assume you have a role based permission model where users can have one role and one role provide a list of permissions. (eg. "Admin" role will get all permissions and "User" will get less permission).
You will probably have an Admin Outline where you can modify the role associated to each of your users. In the ProcessService where you store the user-role modification, you might need to call clearCache() after the relation modification.

If you know that modifications only concern a set of user (modifying the user-role relation is a good example), you can invalidate the cache for only this set of users:
SERVICES.getService(IAccessControlService.class).clearCacheOfUserIds(Collections.singleton(formData.getUserId().getValue()))

If you modify the list of permissions for a role with an other service you should probably invalidate the whole cache.

---

For your use case: "reload permissions on log-in", I did not test it completely, but I guess you can invalidate the cache for the current user in execLoadSerssion() of your ServerSession.

@Override
protected void execLoadSession() throws ProcessingException {
  logger.info("created a new session for " + getUserId());
  SERVICES.getService(IAccessControlService.class).clearCacheOfUserIds(Collections.singleton(getUserId()));
}

Re: AccessControlService execLoadPermissions() called a lot [message #1709779 is a reply to message #1709740] Wed, 30 September 2015 23:17 Go to previous message
Nejc Gasper is currently offline Nejc GasperFriend
Messages: 55
Registered: July 2014
Member
While I agree with you regarding clearing cache. It seemed fine at the moment we did it (A while ago now). Will definitely remove it.

Also your proposal of using execLoadSession seems fine. I actually do not *need* to clear permission cache every time we log-in anymore. This was a past requirement, but we do need to be able to clear it once in a while. So now I have a way to know when user logs in, this is nice. Stupid of us to have missed that.

Other than this I am actually still trying to reproduce this somehow, it seems that in my setup calling clearCache inside execLoadPermissions was the trigger. Will take a few more hours to check things and if I cannot reproduce this in a meaningful way... even better. Thanks again for help.
Previous Topic:[Blog Post] Maven repository for Mylyn Wikitext
Next Topic:Clearing cell decorations in editable table cell
Goto Forum:
  


Current Time: Mon Dec 02 16:31:30 GMT 2024

Powered by FUDForum. Page generated in 0.03830 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top