edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector
Class StoredIDStore

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.StoredIDStore

public class StoredIDStore
extends Object

Represents as persistent, database-backed, store of identifiers. The DDL for the database is CREATE TABLE shibpid {localEntity VARCHAR NOT NULL, peerEntity VARCHAR NOT NULL, principalName VARCHAR NOT NULL, localId VARCHAR NOT NULL, persistentId VARCHAR NOT NULL, peerProvidedId VARCHAR, creationDate TIMESTAMP NOT NULL, deactivationDate TIMESTAMP} .


Nested Class Summary
 class StoredIDStore.PersistentIdEntry
          Data object representing a persistent identifier entry in the database.
 
Field Summary
private  String createTimeColumn
          Name of the creation time column.
private  DataSource dataSource
          JDBC data source for retrieving connections.
private  String deactivateIdSQL
          SQL used to deactivate an ID.
private  String deactivationTimeColumn
          Name of the deactivation time column.
private  String idEntrySelectSQL
          Partial select query for ID entries.
private  String localEntityColumn
          Name of the local entity ID column.
private  String localIdColumn
          Name of the local ID column.
private  org.slf4j.Logger log
          Class logger.
private  String peerEntityColumn
          Name of the peer entity ID name column.
private  String peerProvidedIdColumn
          ID, provided by peer, associated with the persistent ID.
private  String persistentIdColumn
          Name of the persistent ID column.
private  String principalNameColumn
          Name of the principal name column.
private  int queryTimeout
          Timeout of SQL queries in seconds.
private  String table
          Name of the database table.
 
Constructor Summary
StoredIDStore(DataSource source, int timeout)
          Constructor.
 
Method Summary
protected  List<StoredIDStore.PersistentIdEntry> buildIdentifierEntries(ResultSet resultSet)
          Builds a list of StoredIDStore.PersistentIdEntrys from a result set.
 void deactivatePersistentId(String persistentId, Timestamp deactivation)
          Deactivates a given persistent ID.
 StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String persistentId)
          Gets the persistent ID entry for the given ID.
 StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String localEntity, String peerEntity, String localId)
          Gets the currently active identifier entry for a (principal, peer, local) tuple.
 StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String localEntity, String peerEntity, String localId, boolean isActive)
           
 List<StoredIDStore.PersistentIdEntry> getDeactivatedPersistentIdEntries(String localEntity, String peerEntity, String localId)
          Gets the list of deactivated IDs for a given (principal, peer, local) tuple.
 int getNumberOfPersistentIdEntries(String localEntity, String peerEntity, String localId)
          Gets the number of persistent ID entries for a (principal, peer, local) tuple.
 List<StoredIDStore.PersistentIdEntry> getPersistentIdEntries(String localEntity, String peerEntity, String localId)
          Gets all the persistent ID entries for a (principal, peer, local) tuple.
 StoredIDStore.PersistentIdEntry getPersistentIdEntry(String persistentId, boolean onlyActiveId)
          Gets the persistent ID entry for the given ID.
 void storePersistentIdEntry(StoredIDStore.PersistentIdEntry entry)
          Stores a persistent ID entry into the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final org.slf4j.Logger log
Class logger.


dataSource

private DataSource dataSource
JDBC data source for retrieving connections.


queryTimeout

private int queryTimeout
Timeout of SQL queries in seconds.


table

private final String table
Name of the database table.

See Also:
Constant Field Values

localEntityColumn

private final String localEntityColumn
Name of the local entity ID column.

See Also:
Constant Field Values

peerEntityColumn

private final String peerEntityColumn
Name of the peer entity ID name column.

See Also:
Constant Field Values

principalNameColumn

private final String principalNameColumn
Name of the principal name column.

See Also:
Constant Field Values

localIdColumn

private final String localIdColumn
Name of the local ID column.

See Also:
Constant Field Values

persistentIdColumn

private final String persistentIdColumn
Name of the persistent ID column.

See Also:
Constant Field Values

peerProvidedIdColumn

private final String peerProvidedIdColumn
ID, provided by peer, associated with the persistent ID.

See Also:
Constant Field Values

createTimeColumn

private final String createTimeColumn
Name of the creation time column.

See Also:
Constant Field Values

deactivationTimeColumn

private final String deactivationTimeColumn
Name of the deactivation time column.

See Also:
Constant Field Values

idEntrySelectSQL

private final String idEntrySelectSQL
Partial select query for ID entries.

See Also:
Constant Field Values

deactivateIdSQL

private final String deactivateIdSQL
SQL used to deactivate an ID.

See Also:
Constant Field Values
Constructor Detail

StoredIDStore

public StoredIDStore(DataSource source,
                     int timeout)
Constructor.

Parameters:
source - datasource used to communicate with the database
timeout - SQL query timeout in seconds
Method Detail

getNumberOfPersistentIdEntries

public int getNumberOfPersistentIdEntries(String localEntity,
                                          String peerEntity,
                                          String localId)
                                   throws SQLException
Gets the number of persistent ID entries for a (principal, peer, local) tuple.

Parameters:
localEntity - entity ID of the ID issuer
peerEntity - entity ID of the peer the ID is for
localId - local ID part of the persistent ID
Returns:
the number of identifiers
Throws:
SQLException - thrown if there is a problem communication with the database

getPersistentIdEntries

public List<StoredIDStore.PersistentIdEntry> getPersistentIdEntries(String localEntity,
                                                                    String peerEntity,
                                                                    String localId)
                                                             throws SQLException
Gets all the persistent ID entries for a (principal, peer, local) tuple.

Parameters:
localId - local ID part of the persistent ID
peerEntity - entity ID of the peer the ID is for
localEntity - entity ID of the ID issuer
Returns:
the active identifier
Throws:
SQLException - thrown if there is a problem communication with the database

getActivePersistentIdEntry

public StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String persistentId)
                                                           throws SQLException
Gets the persistent ID entry for the given ID.

Parameters:
persistentId - the persistent ID
Returns:
the ID entry for the given ID
Throws:
SQLException - thrown if there is a problem communication with the database

getPersistentIdEntry

public StoredIDStore.PersistentIdEntry getPersistentIdEntry(String persistentId,
                                                            boolean onlyActiveId)
                                                     throws SQLException
Gets the persistent ID entry for the given ID.

Parameters:
persistentId - the persistent ID
onlyActiveId - true if only an active ID should be returned, false if a deactivated ID may be returned
Returns:
the ID entry for the given ID
Throws:
SQLException - thrown if there is a problem communication with the database

getActivePersistentIdEntry

public StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String localEntity,
                                                                  String peerEntity,
                                                                  String localId,
                                                                  boolean isActive)
                                                           throws SQLException
Throws:
SQLException

getActivePersistentIdEntry

public StoredIDStore.PersistentIdEntry getActivePersistentIdEntry(String localEntity,
                                                                  String peerEntity,
                                                                  String localId)
                                                           throws SQLException
Gets the currently active identifier entry for a (principal, peer, local) tuple.

Parameters:
localId - local ID part of the persistent ID
peerEntity - entity ID of the peer the ID is for
localEntity - entity ID of the ID issuer
Returns:
the active identifier
Throws:
SQLException - thrown if there is a problem communication with the database

getDeactivatedPersistentIdEntries

public List<StoredIDStore.PersistentIdEntry> getDeactivatedPersistentIdEntries(String localEntity,
                                                                               String peerEntity,
                                                                               String localId)
                                                                        throws SQLException
Gets the list of deactivated IDs for a given (principal, peer, local) tuple.

Parameters:
localId - local component of the Id
peerEntity - entity ID of the peer the ID is for
localEntity - entity ID of the ID issuer
Returns:
list of deactivated identifiers
Throws:
SQLException - thrown if there is a problem communication with the database

storePersistentIdEntry

public void storePersistentIdEntry(StoredIDStore.PersistentIdEntry entry)
                            throws SQLException
Stores a persistent ID entry into the database.

Parameters:
entry - entry to persist
Throws:
SQLException - thrown is there is a problem writing to the database

deactivatePersistentId

public void deactivatePersistentId(String persistentId,
                                   Timestamp deactivation)
                            throws SQLException
Deactivates a given persistent ID.

Parameters:
persistentId - ID to deactivate
deactivation - deactivation time, if null the current time is used
Throws:
SQLException - thrown if there is a problem communication with the database

buildIdentifierEntries

protected List<StoredIDStore.PersistentIdEntry> buildIdentifierEntries(ResultSet resultSet)
                                                                throws SQLException
Builds a list of StoredIDStore.PersistentIdEntrys from a result set.

Parameters:
resultSet - the result set
Returns:
list of StoredIDStore.PersistentIdEntrys
Throws:
SQLException - thrown if there is a problem reading the information from the database


Copyright © 1999-2012. All Rights Reserved.