Class 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 Detail

      • EntryAttributeToUserTypeMapper

        public EntryAttributeToUserTypeMapper()
    • Method Detail

      • getUserTypeAttribute

        protected com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPAttribute getUserTypeAttribute​(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry,
                                                                                            LdapAttributeMapper mapper)
        Extracts the LDAPAttribute which represents the LDAPEntry's group membership. This is accomplished by querying the given LdapAttributeMapper for an attribute name corresponding to getLogicalAttributeName().
        Parameters:
        ldapEntry - the LDAPEntry from which to extract a LDAPAttribute
        mapper - a container for attribute mapping config
        Returns:
        a user type LDAPAttribute or null if none could be found on the given LDAPEntry
      • 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, to mapUserTypeAttributeValue(String). Exits with the first non-null return from that method or a value dependent on current value of isReturnLiteralAttributeValueIfNoMapping()
        Parameters:
        attrValues - String values to test
        Returns:
        a Sakai user type, possibly null
      • mapUserTypeAttributeValue

        protected String mapUserTypeAttributeValue​(String attrValue)
        Effectively the same as getAttributeValueToSakaiUserTypeMap().get(attrValue). Returns null if no mapping has been assigned.
        Parameters:
        attrValue - the attribute value to map
        Returns:
        the mapped value or null if 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
      • 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. If true, mapLdapEntryToSakaiUserType(LDAPEntry, LdapAttributeMapper) will return the first attribute value encountered, otherwise will return the current value of getDefaultSakaiUserType(). Defaults to false.
        Returns:
        true if 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()