public final class LDAPUtils extends Object
LDAPUtils.prioritizeServers(java.util.Set, java.lang.String, java.lang.String)
, which will be prioritized based on the
current server's server ID/site ID.LDAPURL
objects, or you can pass in the list to the newPrioritized* methods.Modifier and Type | Field and Description |
---|---|
static org.forgerock.util.Option<Boolean> |
AFFINITY_ENABLED
An
Option that tells whether affinity based load balancing is enabled for the connections. |
Modifier and Type | Method and Description |
---|---|
static void |
addAttributeToMapAsByteArray(org.forgerock.opendj.ldap.Attribute attribute,
Map<String,byte[][]> map)
Converts the Attribute to an attribute name, 2-dimensional byte array map and adds it to the map passed in.
|
static void |
addAttributeToMapAsString(org.forgerock.opendj.ldap.Attribute attribute,
Map<String,Set<String>> map)
Converts the Attribute to an attribute name, set of String values map and adds it to the map passed in.
|
static Set<String> |
collectNonIdenticalValues(org.forgerock.opendj.ldap.DN compare,
Set<String> dns)
Returns a set of all the non-root DNs from the collection that are not equal to the
compare parameter. |
static Set<LDAPURL> |
convertToLDAPURLs(Set<String> servers)
Converts the incoming set of URLs to
LDAPURL instances and returns them as a set. |
static org.forgerock.opendj.ldap.ConnectionFactory |
createFailoverConnectionFactory(String host,
int defaultPort,
boolean ssl,
String authDN,
String authPasswd,
org.forgerock.util.Options options)
Creates a ConnectionFactory from the host string and associated details.
|
static boolean |
dnEquals(String dn1,
String dn2)
Determines if the DN's are equal.
|
static String |
escapeValue(String str)
Escapes characters that should be escaped.
|
static String |
formatToRFC(String dn)
Converts a DN String to a RFC format and lowers case.
|
static Set<String> |
getAttributeValuesAsStringSet(org.forgerock.opendj.ldap.Attribute attribute)
Converts all the attribute values to a String Set.
|
static String |
getDBName(String suffix,
org.forgerock.opendj.ldap.Connection ld)
Gets the DB name.
|
static Set<LDAPURL> |
getLdapUrls(Set<LDAPURL> ldapServers,
boolean isSSL)
Converts the ldapServers and ssl into LDAPURL and add it into a Set.
|
static Set<LDAPURL> |
getLdapUrls(String serverName,
int port,
boolean isSSL)
Converts the serverName, port and ssl into LDAPURL and add it into a Set.
|
static String |
getName(org.forgerock.opendj.ldap.DN dn)
Returns the RDN without the attribute name from the passed in
DN object, for example:
uid=demo,ou=people,dc=example,dc=com will return demo . |
static org.forgerock.opendj.ldap.SearchScope |
getSearchScope(String scope,
org.forgerock.opendj.ldap.SearchScope defaultScope)
Converts string representation of scope (as defined in the configuration) to the corresponding
SearchScope object. |
static boolean |
isDN(String candidateDN)
Tests whether the supplied string is a DN, and is not the root DN.
|
static org.forgerock.opendj.ldap.DN |
newDN(String orgName)
Creates a DN from the specified DN string.
|
static org.forgerock.opendj.ldap.ConnectionFactory |
newFailoverConnectionFactory(Set<LDAPURL> servers,
String username,
char[] password,
int heartBeatInterval,
String heartBeatTimeUnit,
boolean useStartTLS,
boolean sslTrustAll,
org.forgerock.util.Options ldapOptions)
Creates a new connection factory that is capable to failover to the servers defined in case there is an error.
|
static org.forgerock.opendj.ldap.ConnectionFactory |
newFailoverConnectionPool(Set<LDAPURL> servers,
String username,
char[] password,
int maxSize,
int heartBeatInterval,
String heartBeatTimeUnit,
boolean useStartTLS,
boolean sslTrustAll,
org.forgerock.util.Options ldapOptions)
Creates a new connection pool that is capable to failover to the servers defined in case there is an error.
|
static org.forgerock.opendj.ldap.ConnectionFactory |
newPrioritizedFailoverConnectionFactory(Set<String> servers,
String hostServerId,
String hostSiteId,
String username,
char[] password,
int heartBeatInterval,
String heartBeatTimeUnit,
boolean useStartTLS,
boolean sslTrustAll,
org.forgerock.util.Options options)
Based on the incoming parameters prioritizes the LDAP server list, then creates a connection factory that is
capable to failover to the servers defined in case there is an error.
|
static org.forgerock.opendj.ldap.ConnectionFactory |
newPrioritizedFailoverConnectionPool(Set<String> servers,
String hostServerId,
String hostSiteId,
String username,
char[] password,
int maxSize,
int heartBeatInterval,
String heartBeatTimeUnit,
boolean useStartTLS,
boolean sslTrustAll,
org.forgerock.util.Options ldapOptions)
Based on the incoming parameters prioritizes the LDAP server list, then creates a connection pool that is
capable to failover to the servers defined in case there is an error.
|
static String |
normalizeDN(String dn)
Normalizes the DN.
|
static org.forgerock.opendj.ldap.Filter |
parseFilter(String filter,
org.forgerock.opendj.ldap.Filter defaultFilter)
Parses the incoming filter, and in case of failure falls back to the default filter.
|
static String |
partiallyEscapeAssertionValue(String assertionValue)
Escapes the provided assertion value according to the LDAP standard.
|
static Set<LDAPURL> |
prioritizeServers(Set<String> servers,
String hostServerId,
String hostSiteId)
Prioritizes the incoming LDAP servers based on their assigned servers/sites.
|
static String |
rdnType(org.forgerock.opendj.ldap.RDN rdn)
When provided an RDN, returns the attribute type name.
|
static String |
rdnTypeFromDn(org.forgerock.opendj.ldap.DN dn)
When provided a DN, returns the attribute type name of the first RDN.
|
static String |
rdnTypeFromDn(String dn)
When provided a DN, returns the attribute type name of the first RDN.
|
static String |
rdnValue(org.forgerock.opendj.ldap.RDN rdn)
When provided an RDN, returns the value part.
|
static String |
rdnValueFromDn(org.forgerock.opendj.ldap.DN dn)
When provided a DN, returns the value part of the first RDN.
|
static String |
rdnValueFromDn(String dn)
When provided a DN, returns the value part of the first RDN.
|
public static final org.forgerock.util.Option<Boolean> AFFINITY_ENABLED
Option
that tells whether affinity based load balancing is enabled for the connections.public static org.forgerock.opendj.ldap.ConnectionFactory newPrioritizedFailoverConnectionPool(Set<String> servers, String hostServerId, String hostSiteId, String username, char[] password, int maxSize, int heartBeatInterval, String heartBeatTimeUnit, boolean useStartTLS, boolean sslTrustAll, org.forgerock.util.Options ldapOptions)
servers
- The set of servers in the format defined in LDAPUtils.prioritizeServers(java.util.Set, java.lang.String, java.lang.String)
.hostServerId
- The server ID for this OpenAM server.hostSiteId
- The site ID for this OpenAM server.username
- The directory user's DN. May be null if this is an anonymous connection.password
- The directory user's password.maxSize
- The max size of the created pool.heartBeatInterval
- The interval for sending out heartbeat requests.heartBeatTimeUnit
- The timeunit for the heartbeat interval.useStartTLS
- Use StartTLS to connect to the LDAP Server(s).sslTrustAll
- trust all certs to connect to the LDAPS Server(s).ldapOptions
- Additional LDAP settings used to create the pool.public static org.forgerock.opendj.ldap.ConnectionFactory newFailoverConnectionPool(Set<LDAPURL> servers, String username, char[] password, int maxSize, int heartBeatInterval, String heartBeatTimeUnit, boolean useStartTLS, boolean sslTrustAll, org.forgerock.util.Options ldapOptions)
servers
- The set of LDAP URLs that will be used to set up the connection factory.username
- The directory user's DN. May be null if this is an anonymous connection.password
- The directory user's password.maxSize
- The max size of the created pool.heartBeatInterval
- The interval for sending out heartbeat requests.heartBeatTimeUnit
- The timeunit for the heartbeat interval.useStartTLS
- Use StartTLS to connect to the LDAP Server(s).sslTrustAll
- trust all certs to connect to the LDAPS Server(s).ldapOptions
- Additional LDAP settings used to create the poolpublic static org.forgerock.opendj.ldap.ConnectionFactory newPrioritizedFailoverConnectionFactory(Set<String> servers, String hostServerId, String hostSiteId, String username, char[] password, int heartBeatInterval, String heartBeatTimeUnit, boolean useStartTLS, boolean sslTrustAll, org.forgerock.util.Options options)
servers
- The set of servers in the format defined in LDAPUtils.prioritizeServers(java.util.Set, java.lang.String, java.lang.String)
.hostServerId
- The server ID for this OpenAM server.hostSiteId
- The site ID for this OpenAM server.username
- The directory user's DN. May be null if this is an anonymous connection.password
- The directory user's password.heartBeatInterval
- The interval for sending out heartbeat requests.heartBeatTimeUnit
- The timeunit for the heartbeat interval.useStartTLS
- Use StartTLS to connect to the LDAP Server(s).sslTrustAll
- trust all certs to connect to the LDAPS Server(s).options
- Additional LDAP settings used to create the connection factory.public static org.forgerock.opendj.ldap.ConnectionFactory newFailoverConnectionFactory(Set<LDAPURL> servers, String username, char[] password, int heartBeatInterval, String heartBeatTimeUnit, boolean useStartTLS, boolean sslTrustAll, org.forgerock.util.Options ldapOptions)
servers
- The set of LDAP URLs that will be used to set up the connection factory.username
- The directory user's DN. May be null if this is an anonymous connection.password
- The directory user's password.heartBeatInterval
- The interval for sending out heartbeat requests.heartBeatTimeUnit
- The timeunit for the heartbeat interval.useStartTLS
- Use StartTLS to connect to the LDAP Server(s).sslTrustAll
- trust all certs to connect to the LDAPS Server(s).ldapOptions
- Additional LDAP settings used to create the connection factory.public static Set<LDAPURL> prioritizeServers(Set<String> servers, String hostServerId, String hostSiteId)
host:port
- The LDAP server has no preferred
server/sitehost:port|serverid
- The LDAP server should be mainly
used by an OpenAM instance with the same serveridhost:port|serverid|siteid
- The LDAP server should be
mainly used by an OpenAM instance with the same serverid or with the same
siteidservers
- The Set of servers that needs to be prioritized in the previously described format.hostServerId
- This server's ID.hostSiteId
- This server's site ID.public static org.forgerock.opendj.ldap.SearchScope getSearchScope(String scope, org.forgerock.opendj.ldap.SearchScope defaultScope)
SearchScope
object.scope
- the string representation of the scope.defaultScope
- in case the coversion fail this default scope should be returned.SearchScope
object.public static org.forgerock.opendj.ldap.Filter parseFilter(String filter, org.forgerock.opendj.ldap.Filter defaultFilter)
filter
- The filter that needs to be parsed.defaultFilter
- If the parsing fails, this will be returned.public static String getName(org.forgerock.opendj.ldap.DN dn)
DN
object, for example:
uid=demo,ou=people,dc=example,dc=com
will return demo
.dn
- The DN that we need the name of.public static void addAttributeToMapAsByteArray(org.forgerock.opendj.ldap.Attribute attribute, Map<String,byte[][]> map)
attribute
- The attribute that needs to be converted.map
- The map where the converted attribute is added to.public static void addAttributeToMapAsString(org.forgerock.opendj.ldap.Attribute attribute, Map<String,Set<String>> map)
attribute
- The attribute that needs to be converted.map
- The map where the converted attribute is added to.public static Set<String> getAttributeValuesAsStringSet(org.forgerock.opendj.ldap.Attribute attribute)
attribute
- the attribute to be converted.public static Set<LDAPURL> convertToLDAPURLs(Set<String> servers)
LDAPURL
instances and returns them as a set. The iteration order
of the originally passed in Set is retained.servers
- The LDAP server URLs that needs to be converted to LDAPURL
instances.public static String rdnValueFromDn(String dn)
dn
- A DN.IllegalArgumentException
- When the DN's RDN is multivalued, or when the DN is not a valid name.public static String rdnValueFromDn(org.forgerock.opendj.ldap.DN dn)
dn
- A DN.IllegalArgumentException
- When the DN's RDN is multivalued.public static String rdnValue(org.forgerock.opendj.ldap.RDN rdn)
rdn
- An RDN.IllegalArgumentException
- When the RDN is multivalued.public static String rdnTypeFromDn(String dn)
dn
- A DN.IllegalArgumentException
- When the DN's RDN is multivalued.public static String rdnTypeFromDn(org.forgerock.opendj.ldap.DN dn)
dn
- A DN.IllegalArgumentException
- When the DN's RDN is multivalued.public static String rdnType(org.forgerock.opendj.ldap.RDN rdn)
rdn
- An RDN.IllegalArgumentException
- When the RDN is multivalued.public static Set<String> collectNonIdenticalValues(org.forgerock.opendj.ldap.DN compare, Set<String> dns)
compare
parameter.compare
- The DN to compare against.dns
- THe DNs to compare.Set
of non identical DNs.InvalidNameException
- If an error occurs.public static String getDBName(String suffix, org.forgerock.opendj.ldap.Connection ld)
suffix
- The suffix.ld
- The connection.public static boolean isDN(String candidateDN)
candidateDN
- The possible DN.true
if the string is a DN.public static String escapeValue(String str)
str
- The string to escape.public static String partiallyEscapeAssertionValue(String assertionValue)
assertionValue
- The filter assertionValue that needs to be escaped.public static String normalizeDN(String dn)
dn
- The DN to normalize.public static org.forgerock.opendj.ldap.DN newDN(String orgName)
orgName
- The DN string.public static String formatToRFC(String dn)
dn
- the DN String to be formatedpublic static boolean dnEquals(String dn1, String dn2)
dn1
- The first DN.dn2
- The second DN.true
if the DN's are equal.public static org.forgerock.opendj.ldap.ConnectionFactory createFailoverConnectionFactory(String host, int defaultPort, boolean ssl, String authDN, String authPasswd, org.forgerock.util.Options options)
[host]:[port]
host1 host2 host3
host1:389 host2:50389
ConnectionFactory
is returned. All factories are
pre-authenticated using the supplied credentials.host
- The host/host-port string.defaultPort
- The port number to use for hosts that do not specify a port in the string.ssl
- SSL enabled or not.authDN
- The DN to bind with.authPasswd
- The password to bind with.options
- Any additional options.public static Set<LDAPURL> getLdapUrls(String serverName, int port, boolean isSSL)
serverName
- The LDAP server name.port
- The LDAP server port number.isSSL
- boolean value of true/false for ssl.public static Set<LDAPURL> getLdapUrls(Set<LDAPURL> ldapServers, boolean isSSL)
ldapServers
- The LDAP servers in the format of serverName:portisSSL
- boolean value of true/false for ssl.Copyright © 2010-2016, ForgeRock All Rights Reserved.