Top Description Fields Methods
org.mortbay.jetty

public Interface UserRealm

Imports
java.security.Principal

User Realm. This interface should be specialized to provide specific user lookup and authentication using arbitrary methods. For SSO implementation sof UserRealm should also implement SSORealm.
Author
Greg Wilkins (gregw)
See Also
SSORealm

Field Summary

Modifier and TypeField and Description
public static final Principal
public static final Principal
NOBODY

Nobody user.

public static final Principal

Method Summary

Modifier and TypeMethod and Description
public Principal

Returns:

The authenticated UserPrincipal.
authenticate
(String
The username.
username
,
Object
The user credentials, normally a String password.
credentials
,
Request
The request to be authenticated. Additional parameters may be extracted or set on this request as needed for the authentication mechanism (none required for BASIC and FORM authentication).
request
)

Authenticate a users credentials.

public void
disassociate(Principal
A UserPrincipal allocated from this realm.
user
)

Dissassociate the calling context with a Principal.

public String
public Principal
getPrincipal(String username)

Get the principal for a username.

public boolean

Returns:

True if the user can act in that role.
isUserInRole
(Principal user, String
A role name.
role
)

Check if the user is in a role.

public void
logout(Principal
A Principal previously returned from this realm
user
)

logout a user Principal.

public Principal

Returns:

The principal without the role. Most often this will be the original UserPrincipal passed.
popRole
(Principal
A UserPrincipal previously returned from pushRole
user
)

Pop role from a Principal.

public Principal

Returns:

A new UserPrincipal object that wraps the passed user, but with the added role.
pushRole
(Principal
An existing UserPrincipal or null for an anonymous user.
user
,
String
The role to add.
role
)

Push role onto a Principal.

public boolean

Returns:

True if this user is still authenticated.
reauthenticate
(Principal user)

Re Authenticate a Principal.

Field Detail

NO_USERback to summary
public static final Principal NO_USER
NOBODYback to summary
public static final Principal NOBODY

Nobody user. The Nobody UserPrincipal is used to indicate a partial state of authentication. A request with a Nobody UserPrincipal will be allowed past all authentication constraints - but will not be considered an authenticated request. It can be used by Authenticators such as FormAuthenticator to allow access to logon and error pages within an authenticated URI tree.

NOT_CHECKEDback to summary
public static final Principal NOT_CHECKED

Method Detail

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

Authenticate a users credentials. 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.

Parameters
username:String

The username.

credentials:Object

The user credentials, normally a String password.

request:Request

The request to be authenticated. Additional parameters may be extracted or set on this request as needed for the authentication mechanism (none required for BASIC and FORM authentication).

Returns:Principal

The authenticated UserPrincipal.

disassociateback to summary
public void disassociate(Principal user)

Dissassociate the calling context with a Principal. This method is called when the calling context is not longer associated with the Principal. It should be used by an implementation to remove context associations such as ThreadLocals. The UserPrincipal object remains authenticated, as it may be associated with other contexts.

Parameters
user:Principal

A UserPrincipal allocated from this realm.

getNameback to summary
public String getName()
getPrincipalback to summary
public Principal getPrincipal(String username)

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

isUserInRoleback to summary
public boolean isUserInRole(Principal user, String role)

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)

logout a user Principal. Called by authentication mechanisms (eg FORM) that can detect logout.

Parameters
user:Principal

A Principal previously returned from this realm

popRoleback to summary
public Principal popRole(Principal user)

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)

Push role onto a Principal. This method is used to add a role to an existing principal.

Parameters
user:Principal

An existing UserPrincipal or null for an anonymous user.

role:String

The role to add.

Returns:Principal

A new UserPrincipal object that wraps the passed user, but with the added role.

reauthenticateback to summary
public boolean reauthenticate(Principal user)

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.