public class DatabaseCallbackHandler extends AbstractCallbackHandler implements CallbackHandler
A CallbackHandler
that uses a DB.
Configuration: There are two ways to specify the configuration.
#setConfiguration(Map)
method, which uses String
based key/value pair.#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
.
Modifier and Type | Field and Description |
---|---|
static String |
CONNECTION_URL |
protected String |
connectionUrl
A DB specific connection url
|
static String |
DB_DRIVERNAME |
static String |
DB_USERNAME |
static String |
DB_USERPASS |
protected String |
dbDriverName
A DB Driver Class Name
|
static String |
DS_JNDI_NAME |
protected String |
dsJndiName
JNDI Name of the Datasource
|
protected String |
dsUserName
A DB username to connect
|
protected String |
dsUserPass
A DB password to connect
|
static String |
PRINCIPALS_QUERY |
protected String |
principalsQuery
The sql query to obtain the user password
|
userName
Constructor and Description |
---|
DatabaseCallbackHandler() |
Modifier and Type | Method and 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.JDBCDriver
|
String |
getDsJndiName()
Get the JNDI name of the SQL Datasource
|
String |
getDsUserName()
Get the DB user name
|
String |
getDsUserPass()
Get the DB user pass
|
String |
getPrincipalsQuery() |
String |
getUserName() |
void |
handle(Callback[] callbacks) |
protected void |
handleCallBack(Callback c)
Handle a
Callback |
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 a
Map that contains keys that are strings and values that are strings |
void |
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) |
getUserName
public static final String CONNECTION_URL
public static final String DS_JNDI_NAME
public static final String DB_DRIVERNAME
public static final String DB_USERNAME
public static final String DB_USERPASS
public static final String PRINCIPALS_QUERY
protected String connectionUrl
protected String dsJndiName
protected String dsUserName
protected String dsUserPass
protected String dbDriverName
protected String principalsQuery
public String getConnectionUrl()
public void setConnectionUrl(String connectionUrl)
public String getDsJndiName()
public void setDsJndiName(String dsJndiName)
public String getDsUserName()
public void setDsUserName(String dsUserName)
public String getDsUserPass()
public void setDsUserPass(String dsUserPass)
public String getDbDriverName()
public void setDbDriverName(String dbDriverName)
public String getPrincipalsQuery()
public void setPrincipalsQuery(String principalsQuery)
public String getUserName()
public void setUserName(String theUserName)
public void setConfiguration(Map<String,String> config)
Map
that contains keys that are strings and values that are stringsconfig
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
handle
in interface CallbackHandler
IOException
UnsupportedCallbackException
protected void handleCallBack(Callback c) throws UnsupportedCallbackException, IOException
Callback
c
- callbackUnsupportedCallbackException
- If the callback is not supported by this handlerIOException
protected void handleVerification(VerifyPasswordCallback vpc) throws LoginException
LoginException
protected void safeClose(ResultSet rs)
protected void safeClose(Connection conn)
protected void safeClose(Statement stat)
Copyright © 2021 JBoss by Red Hat. All rights reserved.