I found my answer :

PrincipalCollection pc = new SimplePrincipalCollection(myUserId, "myRealm");
SecurityUtils.getSubject().runAs(pc);

2011/6/1 Nicolas Antoniazzi <[email protected]>

> Hello,
>
> I do not know exactly how to run a specific operation during my process as
> a priviliged user.
> Here is my example where I am logged as a normal user
>
> public void createMyEntity() {
>   myDao.insert(entityToSave); // Operation that can be performed by a
> normal user
>
>   if(entityToSave.hasSpecialProperty()) {
>     myDao.updateSpecialProperty(entityToSave); // Operation that has to be
> performed by special user
>   }
> }
>
> I wanted to use SecurityUtil.getSubject().runAs(), but I do not know how to
> retrieve PrincipalCollections associated to my special user.
> How could I do this ?
>
> Thanks,
>
> Nicolas.
>

Reply via email to