Package org.jboss.security.auth.callback
Class DatabaseCallbackHandler
- java.lang.Object
-
- org.jboss.security.auth.callback.AbstractCallbackHandler
-
- org.jboss.security.auth.callback.DatabaseCallbackHandler
-
- All Implemented Interfaces:
CallbackHandler
public class DatabaseCallbackHandler extends AbstractCallbackHandler implements CallbackHandler
A
CallbackHandler
that uses a DB.Configuration: There are two ways to specify the configuration.
- Using the
#setConfiguration(Map)
method, which usesString
based key/value pair. - Using the methods
#setConnectionUrl(String)
,#setDbDriverName(String)
etc
Either you can specify the connection url, driver class name or you can provide the jndi name of the
DataSource
.- Since:
- Oct 31, 2011
- Author:
- Anil Saldhana
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONNECTION_URL
protected String
connectionUrl
A DB specific connection urlstatic String
DB_DRIVERNAME
static String
DB_USERNAME
static String
DB_USERPASS
protected String
dbDriverName
A DB Driver Class Namestatic String
DS_JNDI_NAME
protected String
dsJndiName
JNDI Name of the Datasourceprotected String
dsUserName
A DB username to connectprotected String
dsUserPass
A DB password to connectstatic String
PRINCIPALS_QUERY
protected String
principalsQuery
The sql query to obtain the user password-
Fields inherited from class org.jboss.security.auth.callback.AbstractCallbackHandler
userName
-
-
Constructor Summary
Constructors Constructor Description DatabaseCallbackHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getConnectionUrl()
Get the DB specific connection URL Eg: "jdbc:hsqldb:mem:unit_test"String
getDbDriverName()
Get the fully qualified name of sql driver class Eg: org.hsqldb.jdbc.JDBCDriverString
getDsJndiName()
Get the JNDI name of the SQL DatasourceString
getDsUserName()
Get the DB user nameString
getDsUserPass()
Get the DB user passString
getPrincipalsQuery()
String
getUserName()
void
handle(Callback[] callbacks)
protected void
handleCallBack(Callback c)
Handle aCallback
protected void
handleVerification(VerifyPasswordCallback vpc)
protected void
safeClose(Connection conn)
protected void
safeClose(ResultSet rs)
protected void
safeClose(Statement stat)
void
setConfiguration(Map<String,String> config)
Set aMap
that contains keys that are strings and values that are stringsvoid
setConnectionUrl(String connectionUrl)
void
setDbDriverName(String dbDriverName)
void
setDsJndiName(String dsJndiName)
void
setDsUserName(String dsUserName)
void
setDsUserPass(String dsUserPass)
void
setPrincipalsQuery(String principalsQuery)
void
setUserName(String theUserName)
-
Methods inherited from class org.jboss.security.auth.callback.AbstractCallbackHandler
getUserName
-
-
-
-
Field Detail
-
CONNECTION_URL
public static final String CONNECTION_URL
- See Also:
- Constant Field Values
-
DS_JNDI_NAME
public static final String DS_JNDI_NAME
- See Also:
- Constant Field Values
-
DB_DRIVERNAME
public static final String DB_DRIVERNAME
- See Also:
- Constant Field Values
-
DB_USERNAME
public static final String DB_USERNAME
- See Also:
- Constant Field Values
-
DB_USERPASS
public static final String DB_USERPASS
- See Also:
- Constant Field Values
-
PRINCIPALS_QUERY
public static final String PRINCIPALS_QUERY
- See Also:
- Constant Field Values
-
connectionUrl
protected String connectionUrl
A DB specific connection url
-
dsJndiName
protected String dsJndiName
JNDI Name of the Datasource
-
dsUserName
protected String dsUserName
A DB username to connect
-
dsUserPass
protected String dsUserPass
A DB password to connect
-
dbDriverName
protected String dbDriverName
A DB Driver Class Name
-
principalsQuery
protected String principalsQuery
The sql query to obtain the user password
-
-
Method Detail
-
getConnectionUrl
public String getConnectionUrl()
Get the DB specific connection URL Eg: "jdbc:hsqldb:mem:unit_test"- Returns:
-
setConnectionUrl
public void setConnectionUrl(String connectionUrl)
-
getDsJndiName
public String getDsJndiName()
Get the JNDI name of the SQL Datasource- Returns:
-
setDsJndiName
public void setDsJndiName(String dsJndiName)
-
getDsUserName
public String getDsUserName()
Get the DB user name- Returns:
-
setDsUserName
public void setDsUserName(String dsUserName)
-
getDsUserPass
public String getDsUserPass()
Get the DB user pass- Returns:
-
setDsUserPass
public void setDsUserPass(String dsUserPass)
-
getDbDriverName
public String getDbDriverName()
Get the fully qualified name of sql driver class Eg: org.hsqldb.jdbc.JDBCDriver- Returns:
-
setDbDriverName
public void setDbDriverName(String dbDriverName)
-
getPrincipalsQuery
public String getPrincipalsQuery()
-
setPrincipalsQuery
public void setPrincipalsQuery(String principalsQuery)
-
getUserName
public String getUserName()
-
setUserName
public void setUserName(String theUserName)
-
setConfiguration
public void setConfiguration(Map<String,String> config)
Set aMap
that contains keys that are strings and values that are strings- Parameters:
config
-
-
handle
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- Specified by:
handle
in interfaceCallbackHandler
- Throws:
IOException
UnsupportedCallbackException
-
handleCallBack
protected void handleCallBack(Callback c) throws UnsupportedCallbackException, IOException
Handle aCallback
- Parameters:
c
- callback- Throws:
UnsupportedCallbackException
- If the callback is not supported by this handlerIOException
-
handleVerification
protected void handleVerification(VerifyPasswordCallback vpc) throws LoginException
- Throws:
LoginException
-
safeClose
protected void safeClose(ResultSet rs)
-
safeClose
protected void safeClose(Connection conn)
-
safeClose
protected void safeClose(Statement stat)
-
-