I need to know if a particular user has an active session in an Ivy application, or in other words whether he is currently loggedin.

I can get a particular IUser with Ivy.session.getWorkflowContext().getSecurityContext().findUser("username") and I can get all the sessions with ivy.session.getWorkflowContext().getSecurityContext().getSessions().

But I cannot find the way to see if the user is part of one of these sessions?

asked 08.03.2012 at 08:40

Emmanuel's gravatar image

Emmanuel
175131619
accept rate: 66%


You can do something like that with the code snippet below:

import ch.ivyteam.ivy.security.ISession;
import ch.ivyteam.ivy.security.IUser;

IUser user = ivy.session.getWorkflowContext().getSecurityContext().findUser("username");
for (ISession session : ivy.session.getWorkflowContext().getSecurityContext().getSessions())
{
    if (session.getSessionUser().equals(user))
    {
        ivy.log.info("Session found with user");
    }
}
link

answered 08.03.2012 at 09:58

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.6k172551
accept rate: 75%

Your answer
toggle preview

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:

×29

Asked: 08.03.2012 at 08:40

Seen: 856 times

Last updated: 08.03.2012 at 08:40