Top Description Fields Constructors Methods
org.mortbay.jetty.plus.jaas

public Class JAASUserRealm

extends Object
implements UserRealm
Class Inheritance
All Implemented Interfaces
org.mortbay.jetty.UserRealm
Known Direct Subclasses
org.mortbay.jetty.plus.jaas.SSOJAASUserRealm
Imports
java.security.Principal, java.security.acl.Group, java.util.ArrayList, .Arrays, .HashMap, .Iterator, .Set, javax.security.auth.login.LoginContext, .LoginException, org.mortbay.jetty.Request, .UserRealm, org.mortbay.jetty.plus.jaas.callback.AbstractCallbackHandler, .DefaultCallbackHandler, org.mortbay.log.Log, org.mortbay.util.Loader

JAASUserRealm

Notes

Usage

Field Summary

Modifier and TypeField and Description
protected String
public static String
public static String[]
protected JAASUserPrincipal
protected String
protected String
protected RoleCheckPolicy
protected String[]

Constructor Summary

AccessConstructor and Description
public
JAASUserRealm()

Constructor.

public
JAASUserRealm(String
the name of the realm
name
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Principal

Returns:

authenticated JAASUserPrincipal or null if authenticated failed
authenticate
(String
provided by the user at login
username
,
Object
provided by the user at login
credentials
,
Request
a Request value
request
)

Implements org.mortbay.jetty.UserRealm.authenticate.

Authenticate a user.
public void
disassociate(Principal
a UserPrincipal to disassociate
user
)

Implements org.mortbay.jetty.UserRealm.disassociate.

Removes any auth info associated with eg.
public String

Returns:

name or null if not set.
getName
()

Implements org.mortbay.jetty.UserRealm.getName.

Get the name of the realm.
public Principal
getPrincipal(String username)

Implements org.mortbay.jetty.UserRealm.getPrincipal.

Get the principal for a username.
public String[]
public java.security.acl.Group
public boolean
isUserInRole(Principal user, String
A role name.
role
)

Implements org.mortbay.jetty.UserRealm.isUserInRole.

Check if the user is in a role.
public void
logout(Principal
an Principal value
user
)

Implements org.mortbay.jetty.UserRealm.logout.

Logout a previously logged in user.
public Principal
popRole(Principal
A UserPrincipal previously returned from pushRole
user
)

Implements org.mortbay.jetty.UserRealm.popRole.

Pop role from a Principal.
public Principal

Returns:

the Principal with the role added
pushRole
(Principal
the Principal to which to add the role
user
,
String
the role name
role
)

Implements org.mortbay.jetty.UserRealm.pushRole.

Temporarily adds a role to a user.
public boolean
reauthenticate(Principal user)

Implements org.mortbay.jetty.UserRealm.reauthenticate.

Re Authenticate a Principal.
public void
public void
setLoginModuleName(String
a String value
name
)

Set the name to use to index into the config file of LoginModules.

public void
setName(String
a String value
name
)

Set the name of the realm

public void
public void
setRoleClassNames(String[] classnames)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callbackHandlerClassback to summary
protected String callbackHandlerClass
DEFAULT_ROLE_CLASS_NAMEback to summary
public static String DEFAULT_ROLE_CLASS_NAME
DEFAULT_ROLE_CLASS_NAMESback to summary
public static String[] DEFAULT_ROLE_CLASS_NAMES
defaultUserback to summary
protected JAASUserPrincipal defaultUser
loginModuleNameback to summary
protected String loginModuleName
realmNameback to summary
protected String realmName
roleCheckPolicyback to summary
protected RoleCheckPolicy roleCheckPolicy
roleClassNamesback to summary
protected String[] roleClassNames

Constructor Detail

JAASUserRealmback to summary
public JAASUserRealm()

Constructor.

JAASUserRealmback to summary
public JAASUserRealm(String name)

Constructor.

Parameters
name:String

the name of the realm

Method Detail

authenticateback to summary
public Principal authenticate(String username, Object credentials, Request request)

Implements org.mortbay.jetty.UserRealm.authenticate.

Authenticate a user.

Parameters
username:String

provided by the user at login

credentials:Object

provided by the user at login

request:Request

a Request value

Returns:Principal

authenticated JAASUserPrincipal or null if authenticated failed

disassociateback to summary
public void disassociate(Principal user)

Implements org.mortbay.jetty.UserRealm.disassociate.

Removes any auth info associated with eg. the thread.

Parameters
user:Principal

a UserPrincipal to disassociate

getNameback to summary
public String getName()

Implements org.mortbay.jetty.UserRealm.getName.

Get the name of the realm.

Returns:String

name or null if not set.

getPrincipalback to summary
public Principal getPrincipal(String username)

Implements org.mortbay.jetty.UserRealm.getPrincipal.

Doc from org.mortbay.jetty.UserRealm.getPrincipal.

Get the principal for a username. This method is not guaranteed to return a Principal for non-authenticated users.

getRoleClassNamesback to summary
public String[] getRoleClassNames()
getRolesback to summary
public java.security.acl.Group getRoles(JAASUserPrincipal principal)
isUserInRoleback to summary
public boolean isUserInRole(Principal user, String role)

Implements org.mortbay.jetty.UserRealm.isUserInRole.

Doc from org.mortbay.jetty.UserRealm.isUserInRole.

Check if the user is in a role.

Parameters
role:String

A role name.

Returns:boolean

True if the user can act in that role.

logoutback to summary
public void logout(Principal user)

Implements org.mortbay.jetty.UserRealm.logout.

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.

Parameters
user:Principal

an Principal value

popRoleback to summary
public Principal popRole(Principal user)

Implements org.mortbay.jetty.UserRealm.popRole.

Doc from org.mortbay.jetty.UserRealm.popRole.

Pop role from a Principal.

Parameters
user:Principal

A UserPrincipal previously returned from pushRole

Returns:Principal

The principal without the role. Most often this will be the original UserPrincipal passed.

pushRoleback to summary
public Principal pushRole(Principal user, String role)

Implements org.mortbay.jetty.UserRealm.pushRole.

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.

Parameters
user:Principal

the Principal to which to add the role

role:String

the role name

Returns:Principal

the Principal with the role added

reauthenticateback to summary
public boolean reauthenticate(Principal user)

Implements org.mortbay.jetty.UserRealm.reauthenticate.

Doc from org.mortbay.jetty.UserRealm.reauthenticate.

Re Authenticate a Principal. Authenicate a principal that has previously been return from the authenticate method. Implementations of this method may adorn the calling context to assoicate it with the authenticated principal (eg ThreadLocals). If such context associations are made, they should be considered valid until a UserRealm.deAuthenticate(UserPrincipal) call is made for this UserPrincipal.

Returns:boolean

True if this user is still authenticated.

setCallbackHandlerClassback to summary
public void setCallbackHandlerClass(String classname)
setLoginModuleNameback to summary
public void setLoginModuleName(String name)

Set the name to use to index into the config file of LoginModules.

Parameters
name:String

a String value

setNameback to summary
public void setName(String name)

Set the name of the realm

Parameters
name:String

a String value

setRoleCheckPolicyback to summary
public void setRoleCheckPolicy(RoleCheckPolicy policy)
setRoleClassNamesback to summary
public void setRoleClassNames(String[] classnames)