Package org.eclipse.jetty.plus.security
Class DataSourceLoginService
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.security.AbstractLoginService
-
- org.eclipse.jetty.plus.security.DataSourceLoginService
-
- All Implemented Interfaces:
LoginService
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
public class DataSourceLoginService extends AbstractLoginService
DataSourceUserRealmObtain user/password/role information from a database via jndi DataSource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DataSourceLoginService.DBUserPrincipal
DBUser-
Nested classes/interfaces inherited from class org.eclipse.jetty.security.AbstractLoginService
AbstractLoginService.RolePrincipal, AbstractLoginService.UserPrincipal
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
_createTables
private javax.sql.DataSource
_datasource
private java.lang.String
_jndiName
private java.lang.String
_roleSql
private java.lang.String
_roleTableKey
private java.lang.String
_roleTableName
private java.lang.String
_roleTableRoleField
private Server
_server
private java.lang.String
_userRoleTableName
private java.lang.String
_userRoleTableRoleKey
private java.lang.String
_userRoleTableUserKey
private java.lang.String
_userSql
private java.lang.String
_userTableKey
private java.lang.String
_userTableName
private java.lang.String
_userTablePasswordField
private java.lang.String
_userTableUserField
private static Logger
LOG
-
Fields inherited from class org.eclipse.jetty.security.AbstractLoginService
_fullValidate, _identityService, _name
-
-
Constructor Summary
Constructors Constructor Description DataSourceLoginService()
DataSourceLoginService(java.lang.String name)
DataSourceLoginService(java.lang.String name, IdentityService identityService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.sql.Connection
getConnection()
boolean
getCreateTables()
java.lang.String
getJndiName()
java.lang.String
getRoleTableKey()
java.lang.String
getRoleTableName()
java.lang.String
getRoleTableRoleField()
Server
getServer()
java.lang.String
getUserRoleTableName()
java.lang.String
getUserRoleTableRoleKey()
java.lang.String
getUserRoleTableUserKey()
java.lang.String
getUserTableKey()
java.lang.String
getUserTableName()
java.lang.String
getUserTablePasswordField()
java.lang.String
getUserTableUserField()
void
initDb()
Lookup the datasource for the jndiName and formulate the necessary sql query strings based on the configured table and column names.java.lang.String[]
loadRoleInfo(AbstractLoginService.UserPrincipal user)
AbstractLoginService.UserPrincipal
loadUserInfo(java.lang.String username)
private void
prepareTables()
void
setCreateTables(boolean createTables)
void
setJndiName(java.lang.String jndi)
void
setRoleTableKey(java.lang.String tableKey)
void
setRoleTableName(java.lang.String tableName)
void
setRoleTableRoleField(java.lang.String tableRoleField)
void
setServer(Server server)
void
setUserRoleTableName(java.lang.String roleTableName)
void
setUserRoleTableRoleKey(java.lang.String roleTableRoleKey)
void
setUserRoleTableUserKey(java.lang.String roleTableUserKey)
void
setUserTableKey(java.lang.String tableKey)
void
setUserTableName(java.lang.String name)
void
setUserTablePasswordField(java.lang.String tablePasswordField)
void
setUserTableUserField(java.lang.String tableUserField)
-
Methods inherited from class org.eclipse.jetty.security.AbstractLoginService
getIdentityService, getName, isFullValidate, login, logout, setFullValidate, setIdentityService, setName, toString, validate
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_jndiName
private java.lang.String _jndiName
-
_datasource
private javax.sql.DataSource _datasource
-
_server
private Server _server
-
_userTableName
private java.lang.String _userTableName
-
_userTableKey
private java.lang.String _userTableKey
-
_userTableUserField
private java.lang.String _userTableUserField
-
_userTablePasswordField
private java.lang.String _userTablePasswordField
-
_roleTableName
private java.lang.String _roleTableName
-
_roleTableKey
private java.lang.String _roleTableKey
-
_roleTableRoleField
private java.lang.String _roleTableRoleField
-
_userRoleTableName
private java.lang.String _userRoleTableName
-
_userRoleTableUserKey
private java.lang.String _userRoleTableUserKey
-
_userRoleTableRoleKey
private java.lang.String _userRoleTableRoleKey
-
_userSql
private java.lang.String _userSql
-
_roleSql
private java.lang.String _roleSql
-
_createTables
private boolean _createTables
-
-
Constructor Detail
-
DataSourceLoginService
public DataSourceLoginService()
-
DataSourceLoginService
public DataSourceLoginService(java.lang.String name)
-
DataSourceLoginService
public DataSourceLoginService(java.lang.String name, IdentityService identityService)
-
-
Method Detail
-
setJndiName
public void setJndiName(java.lang.String jndi)
-
getJndiName
public java.lang.String getJndiName()
-
setServer
public void setServer(Server server)
-
getServer
public Server getServer()
-
setCreateTables
public void setCreateTables(boolean createTables)
-
getCreateTables
public boolean getCreateTables()
-
setUserTableName
public void setUserTableName(java.lang.String name)
-
getUserTableName
public java.lang.String getUserTableName()
-
getUserTableKey
public java.lang.String getUserTableKey()
-
setUserTableKey
public void setUserTableKey(java.lang.String tableKey)
-
getUserTableUserField
public java.lang.String getUserTableUserField()
-
setUserTableUserField
public void setUserTableUserField(java.lang.String tableUserField)
-
getUserTablePasswordField
public java.lang.String getUserTablePasswordField()
-
setUserTablePasswordField
public void setUserTablePasswordField(java.lang.String tablePasswordField)
-
getRoleTableName
public java.lang.String getRoleTableName()
-
setRoleTableName
public void setRoleTableName(java.lang.String tableName)
-
getRoleTableKey
public java.lang.String getRoleTableKey()
-
setRoleTableKey
public void setRoleTableKey(java.lang.String tableKey)
-
getRoleTableRoleField
public java.lang.String getRoleTableRoleField()
-
setRoleTableRoleField
public void setRoleTableRoleField(java.lang.String tableRoleField)
-
getUserRoleTableName
public java.lang.String getUserRoleTableName()
-
setUserRoleTableName
public void setUserRoleTableName(java.lang.String roleTableName)
-
getUserRoleTableUserKey
public java.lang.String getUserRoleTableUserKey()
-
setUserRoleTableUserKey
public void setUserRoleTableUserKey(java.lang.String roleTableUserKey)
-
getUserRoleTableRoleKey
public java.lang.String getUserRoleTableRoleKey()
-
setUserRoleTableRoleKey
public void setUserRoleTableRoleKey(java.lang.String roleTableRoleKey)
-
loadUserInfo
public AbstractLoginService.UserPrincipal loadUserInfo(java.lang.String username)
- Specified by:
loadUserInfo
in classAbstractLoginService
-
loadRoleInfo
public java.lang.String[] loadRoleInfo(AbstractLoginService.UserPrincipal user)
- Specified by:
loadRoleInfo
in classAbstractLoginService
-
initDb
public void initDb() throws javax.naming.NamingException, java.sql.SQLException
Lookup the datasource for the jndiName and formulate the necessary sql query strings based on the configured table and column names.- Throws:
javax.naming.NamingException
- if unable to init jndijava.sql.SQLException
- if unable to init database
-
prepareTables
private void prepareTables() throws javax.naming.NamingException, java.sql.SQLException
- Throws:
javax.naming.NamingException
java.sql.SQLException
-
getConnection
private java.sql.Connection getConnection() throws javax.naming.NamingException, java.sql.SQLException
- Throws:
javax.naming.NamingException
java.sql.SQLException
-
-