Hello,

I need to assign and revoke Ivy Role dynamically on the session user. If I understand the API documentation well, the following method assigns the given role to the session, the role should be automatically unassigned after logout: Ivy.session().assignRole(role);

Here the API documentation:

@PublicAPI(value=EXPERT) Assigns a role to the session. Parameters:role The role to assign

The problem is that I need also to revoke an Ivy Role dynamically, I could not find a method like Ivy.session().revokeRole(IRole role) or Ivy.session().unassignRole(Irole role). Is there a possibility to do that?

Thanks a lot in advance.

Emmanuel

asked 31.03.2016 at 10:26

Emmanuel's gravatar image

Emmanuel
(suspended)
accept rate: 66%


Hello Emmanuel,

you could try ivy.session.getSessionUser().removeRole(ch.ivyteam.ivy.security.IRole) maybe this helps.

best regards

Roland

link

answered 31.03.2016 at 13:34

roland's gravatar image

roland
(suspended)
accept rate: 41%

You can set the assigned role back to it's default value (and behaviour) by assigning the top level role called "everybody".

IRole everybody = Ivy.wf().getSecurityContext().getTopLevelRole();
theSession.assignRole(everybody);

Alternatively you can manage the roles on the session user as roland described:

IUser theUser = Ivy.wf().getSecurityContext().getCurrentSession().getSessionUser();
theUser.addRole(myRole);
theUser.removeRole(myRole);
link

answered 01.04.2016 at 13:44

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×26
×14
×14

Asked: 31.03.2016 at 10:26

Seen: 2,471 times

Last updated: 01.04.2016 at 13:44