You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Sascha <dg...@fishtown-team.de> on 2005/07/07 21:27:42 UTC

getting information about which role/user is logged in ?

Hello,

Is it possible that my Java portlet gets the information which user/role
is currently logged in?

Sascha


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: AW: getting information about which role/user is logged in ?

Posted by Sascha <dg...@fishtown-team.de>.
They aren't in 'jetspeed-security-2.0-M3.jar'...

-----Ursprüngliche Nachricht-----
Von: James Liao [mailto:jian.liao@gmail.com] 
Gesendet: Samstag, 9. Juli 2005 11:47
An: Jetspeed Users List
Betreff: Re: AW: getting information about which role/user is logged in
?

org.apache.jetspeed.security.UserPrincipal
org.apache.jetspeed.security.RolePrincipal


On 7/9/05, Sascha <dg...@fishtown-team.de> wrote:
> I found these classes:
> 
> import java.security.Principal;
> import java.security.AccessController;
> import javax.security.auth.Subject;
> import org.apache.jetspeed.security.SecurityHelper;
> 
> But I still miss 'UserPrincipal.class', 'RolePrincipal.class'
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Sascha [mailto:dgo@fishtown-team.de]
> Gesendet: Samstag, 9. Juli 2005 09:07
> An: 'Jetspeed Users List'; 'James Liao'
> Betreff: AW: AW: getting information about which role/user is logged
in
> ?
> 
> Thank you, James.
> 
> I must confess that my Eclipse can't organize imports of some of your
> mentioned classes. Could you be so kind and tell me where to find them
> (Subject, AccessController, Principal, SecurityHelper, UserPrincipal,
> RolePrincipal)?
> 
> Thank you.
> 
> -----Ursprüngliche Nachricht-----
> Von: James Liao [mailto:jian.liao@gmail.com]
> Gesendet: Freitag, 8. Juli 2005 09:18
> An: Jetspeed Users List
> Betreff: Re: AW: getting information about which role/user is logged
in
> ?
> 
> Hi,
> How about get the info from current context's subject?
> Subject subject = Subject.getSubject(AccessController.getContext());
> Principal user  = SecurityHelper.getPrincipal(subject,
> UserPrincipal.class);
> Principal role =
> SecurityHelper.getPrincipals(user.getSubject(),RolePrincipal.class);
> 
> - James Liao
> 
> On 7/8/05, Luc Fouin <lu...@free.fr> wrote:
> > apache@salesfactory.org a écrit :
> > > Yes, but how can you see who is currently logged in?
> >
> > arf, sorry i misunderstood your question... in this case i can't
> answer...
> >
> > i think you'll have to check the database using the mapping, but i
> can't
> > tell you more...
> >
> > Luc
> >
> >
> > --
> > Luc FOUIN - Stagiaire Aptiwan
> > 14 rue Niepce
> > 75014 Paris
> > Tél : 06 77 95 17 24
> > Mél : luc*DOT*fouin*AT*aptiwan*DOT*com
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail:
jetspeed-user-help@portals.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: AW: getting information about which role/user is logged in ?

Posted by James Liao <ji...@gmail.com>.
org.apache.jetspeed.security.UserPrincipal
org.apache.jetspeed.security.RolePrincipal


On 7/9/05, Sascha <dg...@fishtown-team.de> wrote:
> I found these classes:
> 
> import java.security.Principal;
> import java.security.AccessController;
> import javax.security.auth.Subject;
> import org.apache.jetspeed.security.SecurityHelper;
> 
> But I still miss 'UserPrincipal.class', 'RolePrincipal.class'
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Sascha [mailto:dgo@fishtown-team.de]
> Gesendet: Samstag, 9. Juli 2005 09:07
> An: 'Jetspeed Users List'; 'James Liao'
> Betreff: AW: AW: getting information about which role/user is logged in
> ?
> 
> Thank you, James.
> 
> I must confess that my Eclipse can't organize imports of some of your
> mentioned classes. Could you be so kind and tell me where to find them
> (Subject, AccessController, Principal, SecurityHelper, UserPrincipal,
> RolePrincipal)?
> 
> Thank you.
> 
> -----Ursprüngliche Nachricht-----
> Von: James Liao [mailto:jian.liao@gmail.com]
> Gesendet: Freitag, 8. Juli 2005 09:18
> An: Jetspeed Users List
> Betreff: Re: AW: getting information about which role/user is logged in
> ?
> 
> Hi,
> How about get the info from current context's subject?
> Subject subject = Subject.getSubject(AccessController.getContext());
> Principal user  = SecurityHelper.getPrincipal(subject,
> UserPrincipal.class);
> Principal role =
> SecurityHelper.getPrincipals(user.getSubject(),RolePrincipal.class);
> 
> - James Liao
> 
> On 7/8/05, Luc Fouin <lu...@free.fr> wrote:
> > apache@salesfactory.org a écrit :
> > > Yes, but how can you see who is currently logged in?
> >
> > arf, sorry i misunderstood your question... in this case i can't
> answer...
> >
> > i think you'll have to check the database using the mapping, but i
> can't
> > tell you more...
> >
> > Luc
> >
> >
> > --
> > Luc FOUIN - Stagiaire Aptiwan
> > 14 rue Niepce
> > 75014 Paris
> > Tél : 06 77 95 17 24
> > Mél : luc*DOT*fouin*AT*aptiwan*DOT*com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: AW: getting information about which role/user is logged in ?

Posted by Sascha <dg...@fishtown-team.de>.
I found these classes:

import java.security.Principal;
import java.security.AccessController;
import javax.security.auth.Subject;
import org.apache.jetspeed.security.SecurityHelper;

But I still miss 'UserPrincipal.class', 'RolePrincipal.class'


-----Ursprüngliche Nachricht-----
Von: Sascha [mailto:dgo@fishtown-team.de] 
Gesendet: Samstag, 9. Juli 2005 09:07
An: 'Jetspeed Users List'; 'James Liao'
Betreff: AW: AW: getting information about which role/user is logged in
?

Thank you, James.

I must confess that my Eclipse can't organize imports of some of your
mentioned classes. Could you be so kind and tell me where to find them
(Subject, AccessController, Principal, SecurityHelper, UserPrincipal,
RolePrincipal)?

Thank you.

-----Ursprüngliche Nachricht-----
Von: James Liao [mailto:jian.liao@gmail.com] 
Gesendet: Freitag, 8. Juli 2005 09:18
An: Jetspeed Users List
Betreff: Re: AW: getting information about which role/user is logged in
?

Hi,
How about get the info from current context's subject?
Subject subject = Subject.getSubject(AccessController.getContext());
Principal user  = SecurityHelper.getPrincipal(subject,
UserPrincipal.class);
Principal role =
SecurityHelper.getPrincipals(user.getSubject(),RolePrincipal.class);

- James Liao

On 7/8/05, Luc Fouin <lu...@free.fr> wrote:
> apache@salesfactory.org a écrit :
> > Yes, but how can you see who is currently logged in?
> 
> arf, sorry i misunderstood your question... in this case i can't
answer...
> 
> i think you'll have to check the database using the mapping, but i
can't
> tell you more...
> 
> Luc
> 
> 
> --
> Luc FOUIN - Stagiaire Aptiwan
> 14 rue Niepce
> 75014 Paris
> Tél : 06 77 95 17 24
> Mél : luc*DOT*fouin*AT*aptiwan*DOT*com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: AW: getting information about which role/user is logged in ?

Posted by Sascha <dg...@fishtown-team.de>.
Thank you, James.

I must confess that my Eclipse can't organize imports of some of your
mentioned classes. Could you be so kind and tell me where to find them
(Subject, AccessController, Principal, SecurityHelper, UserPrincipal,
RolePrincipal)?

Thank you.

-----Ursprüngliche Nachricht-----
Von: James Liao [mailto:jian.liao@gmail.com] 
Gesendet: Freitag, 8. Juli 2005 09:18
An: Jetspeed Users List
Betreff: Re: AW: getting information about which role/user is logged in
?

Hi,
How about get the info from current context's subject?
Subject subject = Subject.getSubject(AccessController.getContext());
Principal user  = SecurityHelper.getPrincipal(subject,
UserPrincipal.class);
Principal role =
SecurityHelper.getPrincipals(user.getSubject(),RolePrincipal.class);

- James Liao

On 7/8/05, Luc Fouin <lu...@free.fr> wrote:
> apache@salesfactory.org a écrit :
> > Yes, but how can you see who is currently logged in?
> 
> arf, sorry i misunderstood your question... in this case i can't
answer...
> 
> i think you'll have to check the database using the mapping, but i
can't
> tell you more...
> 
> Luc
> 
> 
> --
> Luc FOUIN - Stagiaire Aptiwan
> 14 rue Niepce
> 75014 Paris
> Tél : 06 77 95 17 24
> Mél : luc*DOT*fouin*AT*aptiwan*DOT*com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: AW: getting information about which role/user is logged in ?

Posted by James Liao <ji...@gmail.com>.
Hi,
How about get the info from current context's subject?
Subject subject = Subject.getSubject(AccessController.getContext());
Principal user  = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
Principal role =
SecurityHelper.getPrincipals(user.getSubject(),RolePrincipal.class);

- James Liao

On 7/8/05, Luc Fouin <lu...@free.fr> wrote:
> apache@salesfactory.org a écrit :
> > Yes, but how can you see who is currently logged in?
> 
> arf, sorry i misunderstood your question... in this case i can't answer...
> 
> i think you'll have to check the database using the mapping, but i can't
> tell you more...
> 
> Luc
> 
> 
> --
> Luc FOUIN - Stagiaire Aptiwan
> 14 rue Niepce
> 75014 Paris
> Tél : 06 77 95 17 24
> Mél : luc*DOT*fouin*AT*aptiwan*DOT*com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: AW: getting information about which role/user is logged in ?

Posted by Luc Fouin <lu...@free.fr>.
apache@salesfactory.org a écrit :
> Yes, but how can you see who is currently logged in?

arf, sorry i misunderstood your question... in this case i can't answer...

i think you'll have to check the database using the mapping, but i can't 
tell you more...

Luc


-- 
Luc FOUIN - Stagiaire Aptiwan
14 rue Niepce
75014 Paris
Tél : 06 77 95 17 24
Mél : luc*DOT*fouin*AT*aptiwan*DOT*com

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: getting information about which role/user is logged in ?

Posted by ap...@salesfactory.org.
Hello,

why doesn't this work:

   TurbineUserManagement tm = new TurbineUserManagement();
    JetspeedRunData jd = (JetspeedRunData)rundata;
    try{
      tm.init(jd);
      Iterator it = tm.getUsers();
      while(it.hasNext())
      {
        BaseJetspeedUser bju = (BaseJetspeedUser)it.next();
        System.out.println("User " + bju.getFirstName() + " on: " +
bju.hasLoggedIn());
      }
    }    

hasLoggedIn() ist allways false.

If I get the user from the session (rundata.getUserFromSession()),
hasLoggedIn() ist true for the current user, but not the others... how can I
get this managed?

Thank you and best regards



-----Ursprüngliche Nachricht-----
Von: Frank Villarreal [mailto:f_villarreal@tetco.com] 
Gesendet: Freitag, 8. Juli 2005 15:40
An: Jetspeed Users List
Betreff: RE: getting information about which role/user is logged in ?


I believe so ... it fires triggers off of session-based events (ie: new
session, timed out session, etc ...).   You can learn more about this from
any book on J2EE Servlets that speaks of Session Listeners.  There are many.

- Frank

> -----Original Message-----
> From: apache@salesfactory.org [mailto:apache@salesfactory.org]
> Sent: Friday, July 08, 2005 08:24 AM
> To: 'Jetspeed Users List'
> Subject: AW: getting information about which role/user is logged in ?
>
>
> Thanks. We're running a single server application.
>
> will the session-listener recignize if a session has been closed due of a
> timeout?
>
>
> thanks
>
> -----Ursprüngliche Nachricht-----
> Von: Frank Villarreal [mailto:f_villarreal@tetco.com]
> Gesendet: Freitag, 8. Juli 2005 15:10
> An: Jetspeed Users List
> Betreff: RE: getting information about which role/user is logged in ?
>
>
> Create a Session Listenser that tracks your user sessions.  You can
> accomplish it that way ... "the catch" is that this type of solution only
> works on a single server application.
>
>
> >
> > Yes, but how can you see who is currently logged in?
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


RE: getting information about which role/user is logged in ?

Posted by Frank Villarreal <f_...@tetco.com>.
I believe so ... it fires triggers off of session-based events (ie: new
session, timed out session, etc ...).   You can learn more about this from
any book on J2EE Servlets that speaks of Session Listeners.  There are many.

- Frank

> -----Original Message-----
> From: apache@salesfactory.org [mailto:apache@salesfactory.org]
> Sent: Friday, July 08, 2005 08:24 AM
> To: 'Jetspeed Users List'
> Subject: AW: getting information about which role/user is logged in ?
>
>
> Thanks. We're running a single server application.
>
> will the session-listener recignize if a session has been closed due of a
> timeout?
>
>
> thanks
>
> -----Ursprüngliche Nachricht-----
> Von: Frank Villarreal [mailto:f_villarreal@tetco.com]
> Gesendet: Freitag, 8. Juli 2005 15:10
> An: Jetspeed Users List
> Betreff: RE: getting information about which role/user is logged in ?
>
>
> Create a Session Listenser that tracks your user sessions.  You can
> accomplish it that way ... "the catch" is that this type of solution only
> works on a single server application.
>
>
> >
> > Yes, but how can you see who is currently logged in?
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: getting information about which role/user is logged in ?

Posted by ap...@salesfactory.org.
Thanks. We're running a single server application. 

will the session-listener recignize if a session has been closed due of a
timeout?


thanks

-----Ursprüngliche Nachricht-----
Von: Frank Villarreal [mailto:f_villarreal@tetco.com] 
Gesendet: Freitag, 8. Juli 2005 15:10
An: Jetspeed Users List
Betreff: RE: getting information about which role/user is logged in ?


Create a Session Listenser that tracks your user sessions.  You can
accomplish it that way ... "the catch" is that this type of solution only
works on a single server application.


>
> Yes, but how can you see who is currently logged in?
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


RE: getting information about which role/user is logged in ?

Posted by Frank Villarreal <f_...@tetco.com>.
Create a Session Listenser that tracks your user sessions.  You can
accomplish it that way ... "the catch" is that this type of solution only
works on a single server application.


>
> Yes, but how can you see who is currently logged in?
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


AW: getting information about which role/user is logged in ?

Posted by ap...@salesfactory.org.
Yes, but how can you see who is currently logged in?

-----Ursprüngliche Nachricht-----
Von: Luc Fouin [mailto:luc.fouin@free.fr] 
Gesendet: Freitag, 8. Juli 2005 07:54
An: Jetspeed Users List
Betreff: Re: getting information about which role/user is logged in ?


Sascha a écrit :
> Hello,
hi,

> 
> Is it possible that my Java portlet gets the information which user/role
> is currently logged in?

usually, you can get get the username with a 
*request.getUserPrincipal()* which gets you a Principal 
http://java.sun.com/j2se/1.5.0/docs/api/java/security/Principal.html

i don't think you can get the roles directly, but, you can check them 
with a *request.isUserInRole(String role)*...


Luc

-- 
Luc FOUIN - Stagiaire Aptiwan
14 rue Niepce
75014 Paris
Tél : 06 77 95 17 24
Mél : luc*DOT*fouin*AT*aptiwan*DOT*com

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: getting information about which role/user is logged in ?

Posted by Luc Fouin <lu...@free.fr>.
Sascha a écrit :
> Hello,
hi,

> 
> Is it possible that my Java portlet gets the information which user/role
> is currently logged in?

usually, you can get get the username with a 
*request.getUserPrincipal()* which gets you a Principal 
http://java.sun.com/j2se/1.5.0/docs/api/java/security/Principal.html

i don't think you can get the roles directly, but, you can check them 
with a *request.isUserInRole(String role)*...


Luc

-- 
Luc FOUIN - Stagiaire Aptiwan
14 rue Niepce
75014 Paris
Tél : 06 77 95 17 24
Mél : luc*DOT*fouin*AT*aptiwan*DOT*com

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org