Package com.nimbusds.common.ldap
Class JSONResultFormatter
- java.lang.Object
-
- com.nimbusds.common.ldap.JSONResultFormatter
-
public class JSONResultFormatter extends Object
Static methods to format complex LDAP result structures as JSON.See the related
LDIFResultFormatter
class for LDIF result formatting.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>
formatAttributeType(com.unboundid.ldap.sdk.schema.AttributeTypeDefinition def)
Formats an attribute type defintion.static Map<String,Object>
formatEntry(com.unboundid.ldap.sdk.Entry entry, Set<String> binary, boolean normalize)
Formats an LDAP directory entry as a JSON object.static Map<String,Object>
formatEntry(com.unboundid.ldap.sdk.Entry entry, Set<String> binary, boolean omitDN, boolean normalize)
Formats an LDAP directory entry as a JSON object.static Map<String,Object>
formatMatchingRule(com.unboundid.ldap.sdk.schema.MatchingRuleDefinition def)
Formats a matching rule defintion.static Map<String,Object>
formatMatchingRuleUse(com.unboundid.ldap.sdk.schema.MatchingRuleUseDefinition def)
Formats a matching rule use defintion.static Map<String,Object>
formatObjectClass(com.unboundid.ldap.sdk.schema.ObjectClassDefinition def)
Formats an object class defintion.static Map<String,Object>
formatSearchResult(com.unboundid.ldap.sdk.SearchResult sr, Set<String> binary, boolean normalize)
Formats a LDAP search result as a JSON object containing matches and referrals.static Map<String,Object>
formatSyntax(com.unboundid.ldap.sdk.schema.AttributeSyntaxDefinition def)
Formats an attribute syntax defintion.
-
-
-
Method Detail
-
formatEntry
public static Map<String,Object> formatEntry(com.unboundid.ldap.sdk.Entry entry, Set<String> binary, boolean omitDN, boolean normalize)
Formats an LDAP directory entry as a JSON object.Format:
{ "DN" : "uid=user001,ou=people,dc=example,dc=com", "attribute-name-1" : [value-1, value-2, value-3, ...], "attribute-name-2" : [value-1, value-2, ...], "attribute-name-3" : [value-1, ...], ... }
- Parameters:
entry
- The directory entry. Must not benull
.binary
- The name of the attributes to Base64 encode. Must not benull
.omitDN
- Iftrue
the DN will be omitted from the returned map.normalize
- Iftrue
attribute names will be converted to lower case.- Returns:
- A JSON object representing the directory entry.
-
formatEntry
public static Map<String,Object> formatEntry(com.unboundid.ldap.sdk.Entry entry, Set<String> binary, boolean normalize)
Formats an LDAP directory entry as a JSON object.Format:
{ "DN" : "uid=user001,ou=people,dc=example,dc=com", "attribute-name-1" : [value-1, value-2, value-3, ...], "attribute-name-2" : [value-1, value-2, ...], "attribute-name-3" : [value-1, ...], ... }
- Parameters:
entry
- The directory entry. Must not benull
.binary
- The name of the attributes to Base64 encode. Must not benull
.normalize
- Iftrue
attribute names will be converted to lower case.- Returns:
- A JSON object representing the directory entry.
-
formatSearchResult
public static Map<String,Object> formatSearchResult(com.unboundid.ldap.sdk.SearchResult sr, Set<String> binary, boolean normalize)
Formats a LDAP search result as a JSON object containing matches and referrals.Format:
{ "matches" : [ { entry-1 }, { entry-2 }, { entry-3 }, ...], "referrals" : [ "url-1", "url-2", "url-3", ...], "page" : { "totalEntryCount" : n, "more" : true|false, "cookie" : "..." }, "vlv" : { "totalEntryCount" : n, "offset" : n, "cookie" : "..." } }
whereentry-n
are formatted by theformatEntry(com.unboundid.ldap.sdk.Entry, java.util.Set<java.lang.String>, boolean, boolean)
method.- Parameters:
sr
- The search result. Must not benull
.binary
- The name of the attributes to Base64 encode. Must not benull
.normalize
- Iftrue
attribute names will be converted to lower case.- Returns:
- A JSON object containing the search result matches, referrals and optional control data.
-
formatObjectClass
public static Map<String,Object> formatObjectClass(com.unboundid.ldap.sdk.schema.ObjectClassDefinition def)
Formats an object class defintion.- Parameters:
def
- The object class definition. Must not benull
.- Returns:
- The object class properties as JSON object.
-
formatAttributeType
public static Map<String,Object> formatAttributeType(com.unboundid.ldap.sdk.schema.AttributeTypeDefinition def)
Formats an attribute type defintion.- Parameters:
def
- The attribute type definition. Must not benull
.- Returns:
- The attribute type properties as JSON object.
-
formatMatchingRule
public static Map<String,Object> formatMatchingRule(com.unboundid.ldap.sdk.schema.MatchingRuleDefinition def)
Formats a matching rule defintion.- Parameters:
def
- The matching rule definition. Must not benull
.- Returns:
- The matching rule properties as JSON object.
-
formatMatchingRuleUse
public static Map<String,Object> formatMatchingRuleUse(com.unboundid.ldap.sdk.schema.MatchingRuleUseDefinition def)
Formats a matching rule use defintion.- Parameters:
def
- The matching rule use definition. Must not benull
.- Returns:
- The matching rule use properties as JSON object.
-
formatSyntax
public static Map<String,Object> formatSyntax(com.unboundid.ldap.sdk.schema.AttributeSyntaxDefinition def)
Formats an attribute syntax defintion.- Parameters:
def
- The attribute syntax definition. Must not benull
.- Returns:
- The syntax properties as JSON object.
-
-