Home

Wrapping functionality to run as system user...

You are here

3 posts / 0 new
Last post
Wrapping functionality to run as system user...

Hello,

I was wondering if there is a way to wrap the execution of certain code so that it is run as the system user or a user with more priveledges.

I am running into an issue where I would like to perform some checks, but the currently authenticated user does not have the priveledges to do so.

Specifically, I have created notification functionality that allows you to alert other users to a document. But, I would like to filter the list of users that can be selected based on whether or not they have read priviledges on the document that is being alerted. Every approach I have tried I have been thwarted.

You help is greatly appreciated.
-Ryan

Ryan Berg
Technology Services Group

Hi

There are two ways to do this

1) Yes, you can run as the system user if you get hold of the AuthenticationComponent. You need to keep the current user and restore the current user in a finally block.

2) Use a non-service bean (which will not have security checks)
This will maintain auditing etc against the current user.
For example there are two node service beans "nodeService" and "NodeService". The first is the internal bean, the second is the public service: the first bean wrapped with security and transactional proxies.

I would suggest selected use of the second approach.

Regards

Andy

Andy Hind
Alfresco Development

Re: Wrapping functionality to run as system user...

This is some great information and it's helping me a bit, but I'm a little confused as to how to configure my system to pick up the non-proxied nodeService. I am writing a Java-backed action that needs to run as the system user. I don't know where to specify the different nodeService in the configuration files.

On the other hand -- I'd like to explore using the AuthenticationComponent as a solution, but I don't know how to get a reference to that from within an action.

Any thoughts?

forums index