public class AttributeMapper extends Object
Transformation map specification:
true
,
causes a JSON string value to be split at each space
character and converted to multiple LDAP attribute values.
On reverse transformation the multiple LDAP attribute values
are joined by a space character into a single JSON string.
Applies only to LDAP attributes of type "string".
The "time" LDAP attribute type is defined in RFC 4517, section 3.3.13. Can only be mapped to positive long integer JSON values representing the number of milliseconds since the Unix epoch.
Example transformation map (as JSON object):
{ "email" : { "ldapAttr" : "mail" }, "age" : { "ldapAttr" : "personAge", "jsonType" : "int" }, "name" : { "ldapAttr" : "cn", "langTag" : true }, "active" : { "ldapAttr" : "accountActive", "jsonType" : "boolean" }, "updated" : { "ldapAttr" : "updateTime", "ldapType" : "time", "jsonType" : "long" }, "groups" : { "ldapAttr" : "isMemberOf", "jsonType" : "string-array", "reMatch" : "cn=([a-zA-Z_0-9 ]+),.*" }, "scope" : { "ldapAttr" : "scopeValues", "split" : true }, "verified" : { "ldapValue" : "TRUE", "jsonType" : "boolean" }, "geo.lat" : { "ldapAttr" : "latitude" }, "geo.long" : { "ldapAttr" : "longitude" } }
Modifier and Type | Field | Description |
---|---|---|
static Pattern |
SPLIT_PATTERN |
The space split pattern.
|
Constructor | Description |
---|---|
AttributeMapper(Map<String,Object> map) |
Creates a new LDAP attribute mapper.
|
Modifier and Type | Method | Description |
---|---|---|
String |
getLDAPAttributeName(String key) |
Gets the name of the LDAP attribute in the transformation map that
matches the specified JSON object member key.
|
String[] |
getLDAPAttributeNames() |
Gets the names of the LDAP attributes in the transformation map.
|
List<String> |
getLDAPAttributeNames(List<String> keys) |
Gets the names of the LDAP attributes in the transformation map that
match the specified JSON object member keys.
|
List<com.unboundid.ldap.sdk.Attribute> |
reverseTransform(net.minidev.json.JSONObject jsonObject) |
Performs a reverse transformation of the specified JSON object
representation of an LDAP entry.
|
net.minidev.json.JSONObject |
transform(com.unboundid.ldap.sdk.Entry ldapEntry) |
Transforms the specified LDAP entry.
|
net.minidev.json.JSONObject |
transform(Map<String,Object> in) |
Transforms the specified
java.util.Map representation of an
LDAP entry. |
public static final Pattern SPLIT_PATTERN
public AttributeMapper(Map<String,Object> map)
map
- The attribute transformation map. Must not be
null
.IllegalArgumentException
- If the attribute transformation map
is not valid.public String[] getLDAPAttributeNames()
public List<String> getLDAPAttributeNames(List<String> keys)
keys
- The JSON object member keys. Must not be null
.public String getLDAPAttributeName(String key)
key
- The JSON object member key. Must not be null
.null
if not
found.public net.minidev.json.JSONObject transform(com.unboundid.ldap.sdk.Entry ldapEntry)
ldapEntry
- The LDAP entry to transform. Must not be
null
.public net.minidev.json.JSONObject transform(Map<String,Object> in)
java.util.Map
representation of an
LDAP entry. Any transformation exceptions are silently ignored.
Note: Language tags are not handled by this method.
in
- The input map, as returned by JSONResultFormatter
,
to transform. Must not be null
.public List<com.unboundid.ldap.sdk.Attribute> reverseTransform(net.minidev.json.JSONObject jsonObject)
jsonObject
- The JSON object to transform in reverse. Must not
be null
.Copyright © 2018 Connect2id. All rights reserved.