## org.mortbay.jetty.plus.jaas
Class JAASUserPrincipal

    java.lang.Object
      org.mortbay.jetty.plus.jaas.JAASUserPrincipal

All Implemented Interfaces:
  Principal

    public class JAASUserPrincipal

extends Object
implements Principal

JAASUserPrincipal

Implements the JAAS version of the org.mortbay.http.UserPrincipal interface.

Version:
  $Id: JAASUserPrincipal.java 1001 2006-09-23 09:31:51Z janb $
Author:
  Jan Bartel (janb)

Nested Class Summary
`static class` `JAASUserPrincipal.RoleStack` RoleStack

Constructor Summary
`JAASUserPrincipal(JAASUserRealm realm, String name)` Constructor.

Method Summary
`void` `disassociate()` Clean out any pushed roles that haven't been popped
`protected LoginContext` `getLoginContext()`
`String` `getName()` Get the name identifying the user
`JAASUserRealm` `getRealm()`
`Group` `getRoles()` Determine the roles that the LoginModule has set
`Subject` `getSubject()` Provide access to the current Subject
`boolean` `isUserInRole(String roleName)` Check if user is in role
`void` `popRole()` Remove temporary association between user and role.
`void` `pushRole(String roleName)` Temporarily associate a user with a role.
`protected void` `setLoginContext(LoginContext loginContext)`
`void` `setRoleCheckPolicy(RoleCheckPolicy policy)` Set the type of checking for isUserInRole
`protected void` `setSubject(Subject subject)` Sets the JAAS subject for this user.
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.security.Principal
`equals, hashCode`

Constructor Detail

### JAASUserPrincipal

    public JAASUserPrincipal(JAASUserRealm realm,
                             String name)

  Constructor.

  Parameters:
    `name` - the name identifying the user

Method Detail

### getRealm

    public JAASUserRealm getRealm()

### isUserInRole

    public boolean isUserInRole(String roleName)

  Check if user is in role

  Parameters:
    `roleName` - role to check
  Returns:
    true or false accordint to the RoleCheckPolicy.

### getRoles

    public Group getRoles()

  Determine the roles that the LoginModule has set

  Returns:
    A `Group` of `Principals` representing the roles this user holds

### setRoleCheckPolicy

    public void setRoleCheckPolicy(RoleCheckPolicy policy)

  Set the type of checking for isUserInRole

  Parameters:
    `policy` -

### pushRole

    public void pushRole(String roleName)

  Temporarily associate a user with a role.

  Parameters:
    `roleName` -

### popRole

    public void popRole()

  Remove temporary association between user and role.

### disassociate

    public void disassociate()

  Clean out any pushed roles that haven't been popped

### getName

    public String getName()

  Get the name identifying the user

  Specified by:
    `getName` in interface `Principal`

### setSubject

    protected void setSubject(Subject subject)

  Sets the JAAS subject for this user. The subject contains:
  - the user's credentials
  - Principal for the user's roles

  Parameters:
    `subject` -

### getSubject

    public Subject getSubject()

  Provide access to the current Subject

### setLoginContext

    protected void setLoginContext(LoginContext loginContext)

### getLoginContext

    protected LoginContext getLoginContext()

### toString

    public String toString()

  Specified by:
    `toString` in interface `Principal`
  Overrides:
    `toString` in class `Object`

Copyright © 1995-2008 Mort Bay Consulting. All Rights Reserved.