org.mortbay.jetty.plus.jaas
Class JAASUserRealm

java.lang.Object
  extended by org.mortbay.jetty.plus.jaas.JAASUserRealm
All Implemented Interfaces:
org.mortbay.jetty.security.UserRealm
Direct Known Subclasses:
SSOJAASUserRealm

public class JAASUserRealm
extends Object
implements org.mortbay.jetty.security.UserRealm

JAASUserRealm

Notes

Usage


Field Summary
protected  String callbackHandlerClass
           
static String DEFAULT_ROLE_CLASS_NAME
           
static String[] DEFAULT_ROLE_CLASS_NAMES
           
protected  JAASUserPrincipal defaultUser
           
protected  String loginModuleName
           
protected  String realmName
           
protected  RoleCheckPolicy roleCheckPolicy
           
protected  String[] roleClassNames
           
 
Constructor Summary
JAASUserRealm()
          Constructor.
JAASUserRealm(String name)
          Constructor.
 
Method Summary
 Principal authenticate(String username, Object credentials, org.mortbay.jetty.Request request)
          Authenticate a user.
 void disassociate(Principal user)
          Removes any auth info associated with eg.
 String getName()
          Get the name of the realm.
 Principal getPrincipal(String username)
           
 String[] getRoleClassNames()
           
 Group getRoles(JAASUserPrincipal principal)
           
 boolean isUserInRole(Principal user, String role)
           
 void logout(Principal user)
          Logout a previously logged in user.
 Principal popRole(Principal user)
           
 Principal pushRole(Principal user, String role)
          Temporarily adds a role to a user.
 boolean reauthenticate(Principal user)
           
 void setCallbackHandlerClass(String classname)
           
 void setLoginModuleName(String name)
          Set the name to use to index into the config file of LoginModules.
 void setName(String name)
          Set the name of the realm
 void setRoleCheckPolicy(RoleCheckPolicy policy)
           
 void setRoleClassNames(String[] classnames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ROLE_CLASS_NAME

public static String DEFAULT_ROLE_CLASS_NAME

DEFAULT_ROLE_CLASS_NAMES

public static String[] DEFAULT_ROLE_CLASS_NAMES

roleClassNames

protected String[] roleClassNames

callbackHandlerClass

protected String callbackHandlerClass

realmName

protected String realmName

loginModuleName

protected String loginModuleName

roleCheckPolicy

protected RoleCheckPolicy roleCheckPolicy

defaultUser

protected JAASUserPrincipal defaultUser
Constructor Detail

JAASUserRealm

public JAASUserRealm()
Constructor.


JAASUserRealm

public JAASUserRealm(String name)
Constructor.

Parameters:
name - the name of the realm
Method Detail

getName

public String getName()
Get the name of the realm.

Specified by:
getName in interface org.mortbay.jetty.security.UserRealm
Returns:
name or null if not set.

setName

public void setName(String name)
Set the name of the realm

Parameters:
name - a String value

setLoginModuleName

public void setLoginModuleName(String name)
Set the name to use to index into the config file of LoginModules.

Parameters:
name - a String value

setCallbackHandlerClass

public void setCallbackHandlerClass(String classname)

setRoleClassNames

public void setRoleClassNames(String[] classnames)

getRoleClassNames

public String[] getRoleClassNames()

setRoleCheckPolicy

public void setRoleCheckPolicy(RoleCheckPolicy policy)

getPrincipal

public Principal getPrincipal(String username)
Specified by:
getPrincipal in interface org.mortbay.jetty.security.UserRealm

isUserInRole

public boolean isUserInRole(Principal user,
                            String role)
Specified by:
isUserInRole in interface org.mortbay.jetty.security.UserRealm

reauthenticate

public boolean reauthenticate(Principal user)
Specified by:
reauthenticate in interface org.mortbay.jetty.security.UserRealm

authenticate

public Principal authenticate(String username,
                              Object credentials,
                              org.mortbay.jetty.Request request)
Authenticate a user.

Specified by:
authenticate in interface org.mortbay.jetty.security.UserRealm
Parameters:
username - provided by the user at login
credentials - provided by the user at login
request - a Request value
Returns:
authenticated JAASUserPrincipal or null if authenticated failed

disassociate

public void disassociate(Principal user)
Removes any auth info associated with eg. the thread.

Specified by:
disassociate in interface org.mortbay.jetty.security.UserRealm
Parameters:
user - a UserPrincipal to disassociate

pushRole

public Principal pushRole(Principal user,
                          String role)
Temporarily adds a role to a user. Temporarily granting a role pushes the role onto a stack of temporary roles. Temporary roles must therefore be removed in order.

Specified by:
pushRole in interface org.mortbay.jetty.security.UserRealm
Parameters:
user - the Principal to which to add the role
role - the role name
Returns:
the Principal with the role added

popRole

public Principal popRole(Principal user)
Specified by:
popRole in interface org.mortbay.jetty.security.UserRealm

getRoles

public Group getRoles(JAASUserPrincipal principal)

logout

public void logout(Principal user)
Logout a previously logged in user. This can only work for FORM authentication as BasicAuthentication is stateless. The user's LoginContext logout() method is called.

Specified by:
logout in interface org.mortbay.jetty.security.UserRealm
Parameters:
user - an Principal value


Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.