|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.internet2.middleware.shibboleth.common.attribute.resolver.provider.AbstractResolutionPlugIn<Map<String,BaseAttribute>>
edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.BaseDataConnector
edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.RDBMSDataConnector
public class RDBMSDataConnector
A data connector that can retrieve information from a relational database through JDBC, version 3.
Nested Class Summary | |
---|---|
static class |
RDBMSDataConnector.DATA_TYPES
Data types understood by this connector. |
Field Summary | |
---|---|
private Map<String,RDBMSColumnDescriptor> |
columnDescriptors
Set of column descriptors for managing returned data. |
private DataSource |
dataSource
JDBC data source for retrieving connections. |
private org.slf4j.Logger |
log
Class logger. |
private boolean |
noResultIsError
Whether an empty result set is an error. |
private TemplateEngine |
queryCreator
Template engine used to change query template into actual query. |
private String |
queryTemplate
Template that produces the query to use. |
private String |
queryTemplateName
Name the query template is registered under with the statement creator. |
private int |
queryTimeout
SQL query timeout in seconds. |
private boolean |
readOnlyConnection
Whether the JDBC connection is read-only. |
private net.sf.ehcache.Cache |
resultsCache
Query result cache. |
private boolean |
usesStoredProcedure
Whether queries might use stored procedures. |
Constructor Summary | |
---|---|
RDBMSDataConnector(DataSource source,
net.sf.ehcache.Cache cache)
Constructor. |
Method Summary | |
---|---|
protected void |
addValueByType(Collection values,
RDBMSDataConnector.DATA_TYPES type,
ResultSet resultSet,
int columnIndex)
Adds a value extracted from the result set as a specific type into the value set. |
protected void |
cacheResult(String principal,
String query,
Map<String,BaseAttribute> attributes)
Caches the attributes resulting from a query. |
Map<String,RDBMSColumnDescriptor> |
getColumnDescriptor()
Gets the set of column descriptors used to deal with result set data. |
int |
getQueryTimeout()
Gets the timeout, in seconds, of the SQL query. |
boolean |
getUsesStoredProcedure()
Gets whether queries made use stored procedures. |
boolean |
isCachingResuts()
Gets whether this data connector is caching results. |
boolean |
isConnectionReadOnly()
Gets whether this data connector uses read-only connections. |
boolean |
isNoResultIsError()
This returns whether this connector will throw an exception if no search results are found. |
protected Map<String,BaseAttribute> |
processResultSet(ResultSet resultSet)
Converts a SQL query results set into a set of BaseAttribute s. |
void |
registerTemplate(TemplateEngine engine,
String template)
This sets the underlying template engine and registers the supplied template. |
Map<String,BaseAttribute> |
resolve(ShibbolethResolutionContext resolutionContext)
Performs the attribute resolution for this plugin. |
protected Map<String,BaseAttribute> |
retrieveAttributesFromCache(String principal,
String query)
Attempts to retrieve the attributes from the cache. |
protected Map<String,BaseAttribute> |
retrieveAttributesFromDatabase(String query)
Attempts to retrieve the attribute from the database. |
void |
setConnectionReadOnly(boolean isReadOnly)
Sets whether this data connector uses read-only connections. |
void |
setNoResultIsError(boolean isError)
This sets whether this connector will throw an exception if no search results are found. |
void |
setQueryTimeout(int timeout)
Sets the timeout, in seconds, of the SQL query. |
void |
setUsesStoredProcedure(boolean storedProcedure)
Sets whether queries made use stored procedures. |
void |
validate()
Validate the internal state of this plug-in. |
Methods inherited from class edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.BaseDataConnector |
---|
getFailoverDependencyId, setFailoverDependencyIds |
Methods inherited from class edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.AbstractResolutionPlugIn |
---|
getDependencyIds, getId, getValuesFromAllDependencies, getValuesFromAttributeDependency, getValuesFromConnectorDependency, setId |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ResolutionPlugIn |
---|
getDependencyIds, getId |
Field Detail |
---|
private final org.slf4j.Logger log
private DataSource dataSource
private TemplateEngine queryCreator
private String queryTemplateName
private String queryTemplate
private int queryTimeout
private boolean readOnlyConnection
private boolean usesStoredProcedure
private boolean noResultIsError
private Map<String,RDBMSColumnDescriptor> columnDescriptors
private net.sf.ehcache.Cache resultsCache
Constructor Detail |
---|
public RDBMSDataConnector(DataSource source, net.sf.ehcache.Cache cache)
source
- data source used to retrieve connectionscache
- cache used to cache resultsMethod Detail |
---|
public void registerTemplate(TemplateEngine engine, String template)
engine
- template engine used to generate the querytemplate
- template used to generate the querypublic boolean isCachingResuts()
public int getQueryTimeout()
public void setQueryTimeout(int timeout)
timeout
- timeout, in seconds, of the SQL querypublic boolean isConnectionReadOnly()
public void setConnectionReadOnly(boolean isReadOnly)
isReadOnly
- whether this data connector uses read-only connectionspublic boolean getUsesStoredProcedure()
public void setUsesStoredProcedure(boolean storedProcedure)
storedProcedure
- whether queries made use stored procedurespublic boolean isNoResultIsError()
boolean
public void setNoResultIsError(boolean isError)
isError
- boolean
public Map<String,RDBMSColumnDescriptor> getColumnDescriptor()
public void validate() throws AttributeResolutionException
AttributeResolutionException
- if the plug-in has an invalid internal statepublic Map<String,BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext) throws AttributeResolutionException
resolutionContext
- the context for the resolution
AttributeResolutionException
- the problem that occurred during the resolutionprotected Map<String,BaseAttribute> retrieveAttributesFromCache(String principal, String query) throws AttributeResolutionException
principal
- the principal name of the user the attributes are forquery
- query used to generate the attributes
AttributeResolutionException
- thrown if there is a problem retrieving data from the cacheprotected Map<String,BaseAttribute> retrieveAttributesFromDatabase(String query) throws AttributeResolutionException
query
- query used to get the attributes
AttributeResolutionException
- thrown if there is a problem retrieving data from the database or
transforming that data into BaseAttribute
sprotected Map<String,BaseAttribute> processResultSet(ResultSet resultSet) throws AttributeResolutionException
BaseAttribute
s.
resultSet
- the result set to convert
AttributeResolutionException
- thrown if there is a problem converting the result set into attributesprotected void addValueByType(Collection values, RDBMSDataConnector.DATA_TYPES type, ResultSet resultSet, int columnIndex) throws SQLException
values
- set to add values intotype
- type the value should be extracted asresultSet
- result set, on the current row, to extract the value fromcolumnIndex
- index of the column from which to extract the attribute
SQLException
- thrown if value can not retrieved from the result setprotected void cacheResult(String principal, String query, Map<String,BaseAttribute> attributes)
principal
- the principal name of the user the attributes are forquery
- the query that generated the attributesattributes
- the results of the query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |