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
CallbackHandlerthat uses a DB.Configuration: There are two ways to specify the configuration.
- Using the
#setConfiguration(Map)method, which usesStringbased 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 StringCONNECTION_URLprotected StringconnectionUrlA DB specific connection urlstatic StringDB_DRIVERNAMEstatic StringDB_USERNAMEstatic StringDB_USERPASSprotected StringdbDriverNameA DB Driver Class Namestatic StringDS_JNDI_NAMEprotected StringdsJndiNameJNDI Name of the Datasourceprotected StringdsUserNameA DB username to connectprotected StringdsUserPassA DB password to connectstatic StringPRINCIPALS_QUERYprotected StringprincipalsQueryThe 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 StringgetConnectionUrl()Get the DB specific connection URL Eg: "jdbc:hsqldb:mem:unit_test"StringgetDbDriverName()Get the fully qualified name of sql driver class Eg: org.hsqldb.jdbc.JDBCDriverStringgetDsJndiName()Get the JNDI name of the SQL DatasourceStringgetDsUserName()Get the DB user nameStringgetDsUserPass()Get the DB user passStringgetPrincipalsQuery()StringgetUserName()voidhandle(Callback[] callbacks)protected voidhandleCallBack(Callback c)Handle aCallbackprotected voidhandleVerification(VerifyPasswordCallback vpc)protected voidsafeClose(Connection conn)protected voidsafeClose(ResultSet rs)protected voidsafeClose(Statement stat)voidsetConfiguration(Map<String,String> config)Set aMapthat contains keys that are strings and values that are stringsvoidsetConnectionUrl(String connectionUrl)voidsetDbDriverName(String dbDriverName)voidsetDsJndiName(String dsJndiName)voidsetDsUserName(String dsUserName)voidsetDsUserPass(String dsUserPass)voidsetPrincipalsQuery(String principalsQuery)voidsetUserName(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 aMapthat contains keys that are strings and values that are strings- Parameters:
config-
-
handle
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- Specified by:
handlein interfaceCallbackHandler- Throws:
IOExceptionUnsupportedCallbackException
-
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)
-
-