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

public Class DataSourceUserRealm

extends HashUserRealm
Class Inheritance
Imports
java.io.IOException, java.security.Principal, java.sql.Connection, .PreparedStatement, .ResultSet, .SQLException, java.util.Properties, javax.naming.InitialContext, .NameNotFoundException, .NamingException, javax.sql.DataSource, org.mortbay.jetty.Request, .Server, org.mortbay.jetty.plus.naming.NamingEntryUtil, org.mortbay.jetty.security.HashUserRealm, org.mortbay.log.Log

DataSourceUserRealm Obtain user/password/role information from a database via jndi DataSource.

Field Summary

Modifier and TypeField and Description
private int
private DataSource
private String
private long
private String
private String
private String
private String
private Server
private String
private String
private String
private String
private String
private String
private String
private String
Inherited from org.mortbay.jetty.security.HashUserRealm:
__SSO_roles_users

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Principal
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
)

Overrides org.mortbay.jetty.security.HashUserRealm.authenticate.

Implements org.mortbay.jetty.UserRealm.authenticate.

Check if user is authentic
public int
private Connection
public String
public String
public String
public Server
public String
public String
public String
public String
public String
public String
public String
private void
initDb()

Lookup the datasource for the jndiName and formulate the necessary sql query strings based on the configured table and column names.

public synchronized boolean

Returns:

True if the user can act in the role.
isUserInRole
(Principal
The user, which must be from this realm
user
,
String roleName)

Overrides org.mortbay.jetty.security.HashUserRealm.isUserInRole.

Implements org.mortbay.jetty.UserRealm.isUserInRole.

Check if a user is in a role.
protected void
loadConfig()

Overrides org.mortbay.jetty.security.HashUserRealm.loadConfig.

Load database configuration from properties file.
private void
loadUser(String user)

Load user's info from database.

public void
setCacheMs(int ms)

public void
public void
public void
setRoleTableRoleField(String tableRoleField)

public void
setServer(Server server)

public void
public void
setUserRoleTableRoleKey(String roleTableRoleKey)

public void
setUserRoleTableUserKey(String roleTableUserKey)

public void
public void
public void
setUserTablePasswordField(String tablePasswordField)

public void
setUserTableUserField(String tableUserField)

Inherited from org.mortbay.jetty.security.HashUserRealm:
addUserToRoleclearSingleSignOndisassociatedoStartdoStopdumpgetConfiggetConfigResourcegetNamegetPrincipalgetRefreshIntervalgetSingleSignOngetSSORealmlogoutpopRolepushRoleputreauthenticatesetConfigsetNamesetRefreshIntervalsetSingleSignOnsetSSORealmtoString

Field Detail

_cacheMsback to summary
private int _cacheMs
_datasourceback to summary
private DataSource _datasource
_jndiNameback to summary
private String _jndiName
_lastHashPurgeback to summary
private long _lastHashPurge
_roleSqlback to summary
private String _roleSql
_roleTableKeyback to summary
private String _roleTableKey
_roleTableNameback to summary
private String _roleTableName
_roleTableRoleFieldback to summary
private String _roleTableRoleField
_serverback to summary
private Server _server
_userRoleTableNameback to summary
private String _userRoleTableName
_userRoleTableRoleKeyback to summary
private String _userRoleTableRoleKey
_userRoleTableUserKeyback to summary
private String _userRoleTableUserKey
_userSqlback to summary
private String _userSql
_userTableKeyback to summary
private String _userTableKey
_userTableNameback to summary
private String _userTableName
_userTablePasswordFieldback to summary
private String _userTablePasswordField
_userTableUserFieldback to summary
private String _userTableUserField

Constructor Detail

DataSourceUserRealmback to summary
public DataSourceUserRealm(String jndiName)
DataSourceUserRealmback to summary
public DataSourceUserRealm()

Method Detail

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

Overrides org.mortbay.jetty.security.HashUserRealm.authenticate.

Implements org.mortbay.jetty.UserRealm.authenticate.

Check if user is authentic

Parameters
username:String

Doc from org.mortbay.jetty.UserRealm.authenticate.

The username.

credentials:Object

Doc from org.mortbay.jetty.UserRealm.authenticate.

The user credentials, normally a String password.

request:Request

Doc from org.mortbay.jetty.UserRealm.authenticate.

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

Doc from org.mortbay.jetty.UserRealm.authenticate.

The authenticated UserPrincipal.

See Also
org.mortbay.jetty.security.HashUserRealm#authenticate(java.lang.String, java.lang.Object, org.mortbay.jetty.Request)
getCacheMsback to summary
public int getCacheMs()
getConnectionback to summary
private Connection getConnection() throws NamingException, SQLException
getRoleTableKeyback to summary
public String getRoleTableKey()
getRoleTableNameback to summary
public String getRoleTableName()
getRoleTableRoleFieldback to summary
public String getRoleTableRoleField()
getServerback to summary
public Server getServer()
getUserRoleTableNameback to summary
public String getUserRoleTableName()
getUserRoleTableRoleKeyback to summary
public String getUserRoleTableRoleKey()
getUserRoleTableUserKeyback to summary
public String getUserRoleTableUserKey()
getUserTableKeyback to summary
public String getUserTableKey()
getUserTableNameback to summary
public String getUserTableName()
getUserTablePasswordFieldback to summary
public String getUserTablePasswordField()
getUserTableUserFieldback to summary
public String getUserTableUserField()
initDbback to summary
private void initDb() throws NamingException

Lookup the datasource for the jndiName and formulate the necessary sql query strings based on the configured table and column names.

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

Overrides org.mortbay.jetty.security.HashUserRealm.isUserInRole.

Implements org.mortbay.jetty.UserRealm.isUserInRole.

Check if a user is in a role.

Parameters
user:Principal

The user, which must be from this realm

Returns:boolean

True if the user can act in the role.

loadConfigback to summary
protected void loadConfig() throws IOException

Overrides org.mortbay.jetty.security.HashUserRealm.loadConfig.

Load database configuration from properties file. This is really here to satisfy the HashUserRealm interface. Setters should be used instead.

loadUserback to summary
private void loadUser(String user)

Load user's info from database.

setCacheMsback to summary
public void setCacheMs(int ms)
setRoleTableKeyback to summary
public void setRoleTableKey(String tableKey)
setRoleTableNameback to summary
public void setRoleTableName(String tableName)
setRoleTableRoleFieldback to summary
public void setRoleTableRoleField(String tableRoleField)
setServerback to summary
public void setServer(Server server)
setUserRoleTableNameback to summary
public void setUserRoleTableName(String roleTableName)
setUserRoleTableRoleKeyback to summary
public void setUserRoleTableRoleKey(String roleTableRoleKey)
setUserRoleTableUserKeyback to summary
public void setUserRoleTableUserKey(String roleTableUserKey)
setUserTableKeyback to summary
public void setUserTableKey(String tableKey)
setUserTableNameback to summary
public void setUserTableName(String name)
setUserTablePasswordFieldback to summary
public void setUserTablePasswordField(String tablePasswordField)
setUserTableUserFieldback to summary
public void setUserTableUserField(String tableUserField)