Package org.sakaiproject.unboundid
Class EntryAttributeToUserTypeMapper
- java.lang.Object
-
- org.sakaiproject.unboundid.EntryAttributeToUserTypeMapper
-
- All Implemented Interfaces:
UserTypeMapper
public class EntryAttributeToUserTypeMapper extends Object implements UserTypeMapper
Maps from a user entry's attribute to a Sakai user type. Will consider attribute values in the order received, returning the first non-null mapping. If no non-null mappings can be found, will return either a configurable default or the first attribute value, unmodified. TODO: could probably refactor to reduce code duplication with EntryContainerRdnToUserTypeMapper- Author:
- Dan McCallum, Unicon Inc
-
-
Constructor Summary
Constructors Constructor Description EntryAttributeToUserTypeMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>getAttributeValueToSakaiUserTypeMap()Retrieve the current attribute value-to-Sakai user type map.StringgetDefaultSakaiUserType()Retrieve the default Sakai user type, which will be returned frommapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper)if no mapping was found andisReturnLiteralAttributeValueIfNoMapping()isfalseStringgetLogicalAttributeName()Access the key to a physical attribute name which will be used to resolve Sakai user types.protected com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPAttributegetUserTypeAttribute(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapAttributeMapper mapper)Extracts theLDAPAttributewhich represents theLDAPEntry's group membership.booleanisReturnLiteralAttributeValueIfNoMapping()Check the behavior when attribute values cannot be mapped to a Sakai user type.StringmapLdapEntryToSakaiUserType(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapAttributeMapper mapper)Maps the attribute values associated with the specifiedLDAPEntryto a Sakai user type.protected StringmapUserTypeAttributeValue(String attrValue)Effectively the same asgetAttributeValueToSakaiUserTypeMap().get(attrValue).protected StringmapUserTypeAttributeValues(String[] attrValues)Maps the given list of attribute values to a single Sakai user type by passing each received String value, in order, tomapUserTypeAttributeValue(String).voidsetAttributeValueToSakaiUserTypeMap(Map<String,String> attributeValueToSakaiUserTypeMap)Assign the attribute value-to-Sakai user type map.voidsetDefaultSakaiUserType(String defaultSakaiUserType)Assign the default Sakai user type.voidsetLogicalAttributeName(String logicalAttributeName)Assign the key to a physical attribute name which will be used to resolve Sakai user types.voidsetReturnLiteralAttributeValueIfNoMapping(boolean returnLiteralAttributeValueIfNoMapping)Assign the behavior for calculating Sakai user types when attribute values fail to map.
-
-
-
Method Detail
-
mapLdapEntryToSakaiUserType
public String mapLdapEntryToSakaiUserType(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapAttributeMapper mapper)
Maps the attribute values associated with the specifiedLDAPEntryto a Sakai user type.setLogicalAttributeName(String)defines the attribute name to consult.setAttributeValueToSakaiUserTypeMap(Map)controls the attribute value mappings.setReturnLiteralAttributeValueIfNoMapping(boolean)controls behavior when attribute value mapping fails.setDefaultSakaiUserType(String)assigns the String to return if attribute value mapping fails and literal value returns have been disabled.- Specified by:
mapLdapEntryToSakaiUserTypein interfaceUserTypeMapper- Parameters:
ldapEntry- theLDAPEntryto mapmapper- a container for attribute mapping config- Returns:
- a Sakai user type, possibly null
- See Also:
getUserTypeAttribute(LDAPEntry, LdapAttributeMapper)
-
getUserTypeAttribute
protected com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPAttribute getUserTypeAttribute(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapAttributeMapper mapper)Extracts theLDAPAttributewhich represents theLDAPEntry's group membership. This is accomplished by querying the givenLdapAttributeMapperfor an attribute name corresponding togetLogicalAttributeName().- Parameters:
ldapEntry- theLDAPEntryfrom which to extract aLDAPAttributemapper- a container for attribute mapping config- Returns:
- a user type
LDAPAttributeornullif none could be found on the givenLDAPEntry
-
mapUserTypeAttributeValues
protected String mapUserTypeAttributeValues(String[] attrValues)
Maps the given list of attribute values to a single Sakai user type by passing each received String value, in order, tomapUserTypeAttributeValue(String). Exits with the first non-nullreturn from that method or a value dependent on current value ofisReturnLiteralAttributeValueIfNoMapping()- Parameters:
attrValues- String values to test- Returns:
- a Sakai user type, possibly null
-
mapUserTypeAttributeValue
protected String mapUserTypeAttributeValue(String attrValue)
Effectively the same asgetAttributeValueToSakaiUserTypeMap().get(attrValue). Returnsnullif no mapping has been assigned.- Parameters:
attrValue- the attribute value to map- Returns:
- the mapped value or
nullif no map or mapping
-
getAttributeValueToSakaiUserTypeMap
public Map<String,String> getAttributeValueToSakaiUserTypeMap()
Retrieve the current attribute value-to-Sakai user type map.- Returns:
- a map of attribute values to Sakai user types
-
setAttributeValueToSakaiUserTypeMap
public void setAttributeValueToSakaiUserTypeMap(Map<String,String> attributeValueToSakaiUserTypeMap)
Assign the attribute value-to-Sakai user type map.- Parameters:
attributeValueToSakaiUserTypeMap- a map of attribute values to Sakai user types
-
getDefaultSakaiUserType
public String getDefaultSakaiUserType()
Retrieve the default Sakai user type, which will be returned frommapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper)if no mapping was found andisReturnLiteralAttributeValueIfNoMapping()isfalse- Returns:
- the default Sakai user type to return from
mapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper)
-
setDefaultSakaiUserType
public void setDefaultSakaiUserType(String defaultSakaiUserType)
Assign the default Sakai user type.- Parameters:
defaultSakaiUserType- the default Sakai user type to return frommapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper)- See Also:
getDefaultSakaiUserType()
-
getLogicalAttributeName
public String getLogicalAttributeName()
Access the key to a physical attribute name which will be used to resolve Sakai user types. Physical names are retrieved by querying theLdapAttributeMapperpassed tomapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper).- Returns:
- a logical attribute name
-
setLogicalAttributeName
public void setLogicalAttributeName(String logicalAttributeName)
Assign the key to a physical attribute name which will be used to resolve Sakai user types.- Parameters:
logicalAttributeName-- See Also:
getLogicalAttributeName()
-
isReturnLiteralAttributeValueIfNoMapping
public boolean isReturnLiteralAttributeValueIfNoMapping()
Check the behavior when attribute values cannot be mapped to a Sakai user type. Iftrue,mapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper)will return the first attribute value encountered, otherwise will return the current value ofgetDefaultSakaiUserType(). Defaults tofalse.- Returns:
trueif failed mappings should return literal attribute values.
-
setReturnLiteralAttributeValueIfNoMapping
public void setReturnLiteralAttributeValueIfNoMapping(boolean returnLiteralAttributeValueIfNoMapping)
Assign the behavior for calculating Sakai user types when attribute values fail to map.- Parameters:
returnLiteralAttributeValueIfNoMapping-- See Also:
isReturnLiteralAttributeValueIfNoMapping()
-
-