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

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.AbstractResolutionPlugIn<Map<String,BaseAttribute>>
      extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.BaseDataConnector
          extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.StoredIDDataConnector
All Implemented Interfaces:
DataConnector, ResolutionPlugIn<Map<String,BaseAttribute>>

public class StoredIDDataConnector
extends BaseDataConnector

A data connector that generates persistent identifiers in one of two ways. The generated attribute has an ID of peristentId and contains a single String value. If a salt is supplied at construction time the generated IDs will be the Base64-encoded SHA-1 hash of the user's principal name, the peer entity ID, and the salt. If a DataSource is supplied the IDs are created and managed as described by StoredIDStore.


Field Summary
private  String generatedAttribute
          ID of the attribute generated by this data connector.
private  org.slf4j.Logger log
          Class logger.
private  StoredIDStore pidStore
          Persistent identifier data store.
private  byte[] salt
          Salt used when computing the ID.
private  String sourceAttribute
          ID of the attribute whose first value is used when generating the computed ID.
 
Constructor Summary
StoredIDDataConnector(DataSource source, int queryTimeout, String generatedAttributeId, String sourceAttributeId, byte[] idSalt)
          Constructor.
 
Method Summary
protected  StoredIDStore.PersistentIdEntry createPersistentId(String principalName, String localEntityId, String peerEntityId, String localId)
          Creates a persistent ID that is unique for a given local/peer/localId tuple.
 String getGeneratedAttributeId()
          Gets the ID of the attribute generated by this connector.
protected  String getLocalId(ShibbolethResolutionContext resolutionContext)
          Gets the local ID component of the persistent ID.
protected  String getPeerEntityId(ShibbolethResolutionContext resolutionContext)
          Gets the entity ID used for the peer.
 byte[] getSalt()
          Gets the salt used when computing the ID.
 String getSourceAttributeId()
          Gets the ID of the attribute whose first value is used when generating the computed ID.
protected  String getStoredId(String principalName, String localEntityId, String peerEntityId, String localId)
          Gets the persistent ID stored in the database.
 StoredIDStore getStoredIDStore()
          Gets the data store used to manage stored IDs.
 Map<String,BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
          Performs the attribute resolution for this plugin.
 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

log

private final org.slf4j.Logger log
Class logger.


pidStore

private StoredIDStore pidStore
Persistent identifier data store.


generatedAttribute

private String generatedAttribute
ID of the attribute generated by this data connector.


sourceAttribute

private String sourceAttribute
ID of the attribute whose first value is used when generating the computed ID.


salt

private byte[] salt
Salt used when computing the ID.

Constructor Detail

StoredIDDataConnector

public StoredIDDataConnector(DataSource source,
                             int queryTimeout,
                             String generatedAttributeId,
                             String sourceAttributeId,
                             byte[] idSalt)
Constructor.

Parameters:
source - datasource used to communicate with the database
queryTimeout - SQL qeury timeout in seconds
generatedAttributeId - ID of the attribute generated by this data connector
sourceAttributeId - ID of the attribute whose first value is used when generating the computed ID
idSalt - salt used when computing the ID
Method Detail

getStoredIDStore

public StoredIDStore getStoredIDStore()
Gets the data store used to manage stored IDs.

Returns:
data store used to manage stored IDs

getSalt

public byte[] getSalt()
Gets the salt used when computing the ID.

Returns:
salt used when computing the ID

getSourceAttributeId

public String getSourceAttributeId()
Gets the ID of the attribute whose first value is used when generating the computed ID.

Returns:
ID of the attribute whose first value is used when generating the computed ID

getGeneratedAttributeId

public String getGeneratedAttributeId()
Gets the ID of the attribute generated by this connector.

Returns:
ID of the attribute generated by this connector

validate

public void validate()
              throws AttributeResolutionException
Validate the internal state of this plug-in. This process may not rely on information from any dependency.

Throws:
AttributeResolutionException - if the plug-in has an invalid internal state

resolve

public Map<String,BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
                                  throws AttributeResolutionException
Performs the attribute resolution for this plugin.

Parameters:
resolutionContext - the context for the resolution
Returns:
the attributes made available by the resolution, never null
Throws:
AttributeResolutionException - the problem that occurred during the resolution

getStoredId

protected String getStoredId(String principalName,
                             String localEntityId,
                             String peerEntityId,
                             String localId)
                      throws AttributeResolutionException
Gets the persistent ID stored in the database. If one does not exist it is created.

Parameters:
principalName - principal name of the user to whom the persistent ID belongs
localEntityId - ID of the local entity associated with the persistent ID
peerEntityId - ID of the peer entity associated with the persistent ID
localId - principal the the persistent ID represents
Returns:
persistent ID
Throws:
AttributeResolutionException - thrown if there is a problem retrieving or storing the persistent ID

getLocalId

protected String getLocalId(ShibbolethResolutionContext resolutionContext)
                     throws AttributeResolutionException
Gets the local ID component of the persistent ID.

Parameters:
resolutionContext - current resolution context
Returns:
local ID component of the persistent ID
Throws:
AttributeResolutionException - thrown if there is a problem resolving the local id

getPeerEntityId

protected String getPeerEntityId(ShibbolethResolutionContext resolutionContext)
Gets the entity ID used for the peer. If the inbound request is a SAML 2 authentication context and contains a NameIDPolicy than the SPNameQualifier is used if present, otherwise the inbound message issuer is used.

Parameters:
resolutionContext - current attribute resolution context
Returns:
the entity ID to use for the peer

createPersistentId

protected StoredIDStore.PersistentIdEntry createPersistentId(String principalName,
                                                             String localEntityId,
                                                             String peerEntityId,
                                                             String localId)
                                                      throws SQLException
Creates a persistent ID that is unique for a given local/peer/localId tuple. If an ID has never been issued for to the given tuple then an ID is created by taking a SHA-1 hash of the peer's entity ID, the local ID, and a salt. This is to ensure compatability with IDs created by the now deprecated ComputedIDDataConnector. If an ID has been issued to the given tuple than a new, random type 4 UUID is generated as the persistent ID.

Parameters:
principalName - principal name of the user to whom the persistent ID belongs
localEntityId - ID of the local entity associated with the persistent ID
peerEntityId - ID of the peer entity associated with the persistent ID
localId - principal the the persistent ID represents
Returns:
the created identifier
Throws:
SQLException - thrown if there is a problem communication with the database


Copyright © 1999-2012. All Rights Reserved.