public class JDBCLoginService extends LoginService
Modifier and Type | Field and Description |
---|---|
private Connection |
conn
The connection to the database
|
private String |
jndiContext
If used, defines the JNDI context from which to get a connection to
the data base
|
private static Logger |
LOG |
private Properties |
properties
When using the DriverManager to connect to the database, this specifies
any additional properties to use when connecting.
|
Constructor and Description |
---|
JDBCLoginService()
Default JavaBean constructor
|
JDBCLoginService(String jndiContext)
Create a new JDBCLoginService and initializes it to connect to a
database using the given params.
|
JDBCLoginService(String driver,
String url)
Create a new JDBCLoginService and initializes it to connect to a
database using the given params.
|
JDBCLoginService(String driver,
String url,
Properties props)
Create a new JDBCLoginService and initializes it to connect to a
database using the given params.
|
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(String name,
char[] password,
String server)
This method is intended to be implemented by clients wishing to
authenticate a user with a given password.
|
private void |
connectByDriverManager(String userName,
char[] password)
Attempts to get a JDBC Connection from a DriverManager.
|
private void |
connectByJNDI(String userName,
char[] password)
Attempts to get a JDBC Connection from a JNDI javax.sql.DataSource, using
that connection for interacting with the database.
|
Connection |
getConnection() |
Properties |
getProperties() |
String |
getUrl() |
void |
setConnection(Connection conn) |
void |
setProperties(Properties properties) |
void |
setUrl(String url) |
addLoginListener, cancelAuthentication, fireLoginCanceled, fireLoginFailed, fireLoginStarted, fireLoginSucceeded, getServer, getSynchronous, getUserRoles, removeLoginListener, setServer, setSynchronous, startAuthentication
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
private Connection conn
private String jndiContext
private Properties properties
public JDBCLoginService(String driver, String url)
driver
- url
- public JDBCLoginService(String driver, String url, Properties props)
driver
- url
- props
- public JDBCLoginService(String jndiContext)
jndiContext
- public JDBCLoginService()
public Properties getProperties()
public void setProperties(Properties properties)
properties
- miscellaneous JDBC properties to use when connecting
to the database via the JDBC driverpublic Connection getConnection()
public void setConnection(Connection conn)
private void connectByJNDI(String userName, char[] password) throws Exception
Exception
private void connectByDriverManager(String userName, char[] password) throws Exception
If, on the other hand, properties is null, it first attempts to connect with a username and password. Failing that, it tries to connect without any credentials at all.
Exception
public boolean authenticate(String name, char[] password, String server) throws Exception
LoginService
authenticate
in class LoginService
name
- user namepassword
- user passwordserver
- Must be either a valid JDBC URL for the type of JDBC driver you are using,
or must be a valid JNDIContext from which to get the database connectiontrue
on authentication successException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses