T
- the target class this mapper can map topublic abstract class LdapAttributesMapper<T> extends Object
Constructor and Description |
---|
LdapAttributesMapper(Map<String,String> mapping)
Creates a mapper based on a mapping from Communote attribute names to LDAP attribute names.
|
LdapAttributesMapper(String mapping)
Convenience constructor to initialize the mapper from a string based mapping definition.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getAttributeValue(Attributes attributes,
String ldapAttributeName)
Returns the value for the named LDAP attribute.
|
protected String |
getAttributeValueForKenmeiAttributeName(String dn,
Attributes attributes,
String communoteAttributeName)
Similar to
getAttributeValue(Attributes, String) but expects a Communote attribute
name which will be automatically mapped to the LDAP attribute name. |
abstract String[] |
getBinaryLdapAttributeName()
Returns an array of names of mapped LDAP attributes that are binary.
|
String |
getLdapAttributName(String name)
Returns the LDAP attribute name for a Communote attribute.
|
String[] |
getMappedLdapAttributeNames()
Returns the names of the mapped LDAP attributes.
|
String |
getMappingAsString()
Returns the mapping of the mapper as string in the form
communoteAttribute1=ldapAttribute1,communoteAttribute2=ldapAttribute2
|
protected abstract Set<String> |
getRequiredAttributeNames()
Returns the subset with required Communote attribute names the mapper can map.
|
protected abstract Set<String> |
getSupportedAttributeNames()
Returns the Kenmei attribute names the mapper can map.
|
protected void |
init(Map<String,String> mapping)
Initializes the mapper and validates that all required properties are contained in the
mapping.
|
boolean |
isKenmeiAttributeMapped(String communoteAttributeName)
Returns whether a Communote attribute is mapped to an LDAP attribute.
|
abstract T |
mapAttributes(String dn,
Attributes ldapAttributes)
Maps the LDAP attributes to the generic type.
|
public LdapAttributesMapper(Map<String,String> mapping) throws LdapAttributeMappingException
mapping
- a mapping from Communote attribute names to LDAP attribute namesLdapAttributeMappingException
- if an attribute is not supported or a required attribute is missingpublic LdapAttributesMapper(String mapping) throws LdapAttributeMappingException
mapping
- a mapping in the form
communoteAttribute1=ldapAttribute1,communoteAttribute2=ldapAttribute2LdapAttributeMappingException
- if an attribute is not supported or a required attribute is missingprotected String getAttributeValue(Attributes attributes, String ldapAttributeName) throws LdapAttributeMappingException
null
is returned. If the attribute has more than one value
only the first will be returned.attributes
- the attributes from which the value should be extractedldapAttributeName
- the name of the attribute in LDAPLdapAttributeMappingException
- if there was an error while retrieving the valueprotected String getAttributeValueForKenmeiAttributeName(String dn, Attributes attributes, String communoteAttributeName) throws LdapAttributeMappingException
getAttributeValue(Attributes, String)
but expects a Communote attribute
name which will be automatically mapped to the LDAP attribute name. If the named attribute is
a required attribute the value must be non-null otherwise an exception is thrown.dn
- Needed for logging.attributes
- the attributes from which the value should be extractedcommunoteAttributeName
- the name of the Communote attribute. The attribute must be one of the
getSupportedAttributeNames()
.LdapAttributeMappingException
- if there was an error while retrieving the value or the attribute name is not
supported or the attribute is required but did not return a valuepublic abstract String[] getBinaryLdapAttributeName()
public String getLdapAttributName(String name)
name
- the namepublic String[] getMappedLdapAttributeNames()
public String getMappingAsString()
protected abstract Set<String> getRequiredAttributeNames()
protected abstract Set<String> getSupportedAttributeNames()
protected void init(Map<String,String> mapping) throws LdapAttributeMappingException
mapping
- the mapping of Kenmei attribute names to LDAP counterparts to validateLdapAttributeMappingException
- if an attribute is not supported or a required attribute is missingpublic boolean isKenmeiAttributeMapped(String communoteAttributeName)
communoteAttributeName
- the Communote attribute to checkpublic abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException
dn
- the DN of the element providing the attributesldapAttributes
- The ldap attributes.LdapAttributeMappingException
- if the mapping failedCopyright © 2019 Communote team. All rights reserved.