Package org.sakaiproject.unboundid
Class EmailAddressDerivingLdapAttributeMapper
- java.lang.Object
-
- org.sakaiproject.unboundid.SimpleLdapAttributeMapper
-
- org.sakaiproject.unboundid.EmailAddressDerivingLdapAttributeMapper
-
- All Implemented Interfaces:
EidDerivedEmailAddressHandler,LdapAttributeMapper
public class EmailAddressDerivingLdapAttributeMapper extends SimpleLdapAttributeMapper implements EidDerivedEmailAddressHandler
-
-
Constructor Summary
Constructors Constructor Description EmailAddressDerivingLdapAttributeMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringderiveAddressFromEid(String rawEid)Calculate an email address from the given user EID.protected StringdoUnpackEidFromAddress(String address)Calculates a user EID from an email address, assuming the address has already passed muster withvalidateAddress(String).StringgetAddressPattern()Access the current email address validation pattern, as assigned bysetAddressPattern(String).StringgetDefaultAddressDomain()voidmapLdapEntryOntoUserData(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapUserData userData)PerformsLDAPEntry-to- attribute mappings.voidsetAddressPattern(String addressPattern)Assign thePatternagainst which strings passed tounpackEidFromAddress(String)must validate in order to be processed bydoUnpackEidFromAddress(String)voidsetDefaultAddressDomain(String domain)Assign the domain to be used when deriving email addresses from user EIDs.StringunpackEidFromAddress(String address)ReturnsdoUnpackEidFromAddress(String)if the givenemail/code> string validates againstvalidateAddress(String).protected booleanvalidateAddress(String address)Validate the given string against thePatternconfigured bysetAddressPattern(String).-
Methods inherited from class org.sakaiproject.unboundid.SimpleLdapAttributeMapper
escapeSearchFilterTerm, getAttributeMapping, getAttributeMappings, getFindUserByAidFilter, getFindUserByCrossAttributeSearchFilter, getFindUserByEidFilter, getFindUserByEmailFilter, getManyUsersInOneSearch, getReverseAttributeMap, getReverseAttributeMappings, getSearchResultAttributes, getUserBindDn, getUserDataDn, getUserTypeMapper, getValueMappings, init, mapLdapAttributeOntoUserData, mapLdapAttributeOntoUserData, mapLdapEntryToSakaiUserType, mapUserDataOntoUserEdit, reverseAttributeMap, setAttributeMappings, setUserDataDn, setUserTypeMapper, setValueMappings, usePreferredFirstName
-
-
-
-
Method Detail
-
unpackEidFromAddress
public String unpackEidFromAddress(String address) throws InvalidEmailAddressException
ReturnsdoUnpackEidFromAddress(String)if the givenemail/code> string validates againstvalidateAddress(String). Otherwise throws a . Throws the same exception type ifdoUnpackEidFromAddress(String)returnsnullor a whitespace string.- Specified by:
unpackEidFromAddressin interfaceEidDerivedEmailAddressHandler- Parameters:
address- and email address. Not necessarily guaranteed to be non-null or even contain valid email syntax- Returns:
- an EID derived from the
emailargument - Throws:
InvalidEmailAddressException- ifemailcannot be processed for any reason. Implementation should raise this exception in any situation where it might otherwise returnnull
-
validateAddress
protected boolean validateAddress(String address)
Validate the given string against thePatternconfigured bysetAddressPattern(String). A null pattern has wildcard semantics.- Parameters:
address- an email address to be validated against some pattern, typically to verify that it belongs to an institutional domain- Returns:
-
doUnpackEidFromAddress
protected String doUnpackEidFromAddress(String address)
Calculates a user EID from an email address, assuming the address has already passed muster withvalidateAddress(String). This implementation strips all characters following the first occurance of '@' and returns the remaining characters.- Parameters:
address- a validated email address- Returns:
- A user EID calculated from the given email address. This EID
is not itself validated in any way. May return
null or whitespace strings.
-
mapLdapEntryOntoUserData
public void mapLdapEntryOntoUserData(com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPEntry ldapEntry, LdapUserData userData)Description copied from class:SimpleLdapAttributeMapperPerformsLDAPEntry-to- attribute mappings. Assigns the givenLDAPEntry's DN to theLdapUserDataas a property keyed byAttributeMappingConstants.USER_DN_PROPERTY. Then iterates overLDAPEntry.getAttributeSet(), handing each attribute toSimpleLdapAttributeMapper.mapLdapAttributeOntoUserData(LDAPAttribute, LdapUserData, Collection). Then enforces the preferred first name field, if it exists. Finally, assigns a "type" to theLdapUserDataas defined bySimpleLdapAttributeMapper.mapLdapEntryToSakaiUserType(LDAPEntry).- Specified by:
mapLdapEntryOntoUserDatain interfaceLdapAttributeMapper- Overrides:
mapLdapEntryOntoUserDatain classSimpleLdapAttributeMapper- Parameters:
ldapEntry- the user's directory entryuserData- targetLdapUserData- See Also:
UserTypeMapper
-
deriveAddressFromEid
public String deriveAddressFromEid(String rawEid)
Calculate an email address from the given user EID. This implementation simply appends the "@" delim and the domain configured bysetDefaultAddressDomain(String). If that value isnull, or the inbound eid isnullor whitespace, simply returnsnull- Parameters:
string-- Returns:
-
getAddressPattern
public String getAddressPattern()
Access the current email address validation pattern, as assigned bysetAddressPattern(String).- Returns:
- a string representation of the currently cached
Pattern. May returnnull
-
setAddressPattern
public void setAddressPattern(String addressPattern)
Assign thePatternagainst which strings passed tounpackEidFromAddress(String)must validate in order to be processed bydoUnpackEidFromAddress(String)- Parameters:
addressPattern- a string to compile into aPattern. Compilation errors are raised immediately without modifications to any already-assigned pattern.nullsaccepted and have wildcard semantics.
-
getDefaultAddressDomain
public String getDefaultAddressDomain()
-
setDefaultAddressDomain
public void setDefaultAddressDomain(String domain)
Assign the domain to be used when deriving email addresses from user EIDs. This is distinct from the pattern configured bysetAddressPattern(String), so there could in fact be many domains from which an EID could be unpacked, but only one domain in which EID-derived email addresses will be created. This behavior can technically be overridden inderiveEmailFromEid(String).- Parameters:
object- some email domain. Not validated. May benull.
-
-