public class LdapUtils extends Object
| Constructor and Description |
|---|
LdapUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeContext(DirContext dirContext)
Closes the directory context.
|
static void |
closeNamingEnumeration(NamingEnumeration<?> namingEnumeration)
Closes the used NamingEnumerations to free up resources.
|
static Name |
escapeDNForSearch(String dn)
This method performs the additional level escaping for ldap search.
|
static String |
escapeSpecialCharactersForFilter(String dnPartial)
Escaping ldap search filter special characters in a string.
|
static String |
getInstanceIdFromThreadLocal()
Takes instance id of the service from the thread local.
|
static String |
getNameInSpaceForUserName(String userName,
String searchBase,
String searchFilter,
DirContext dirContext)
Searches the corresponding name for a given username from LDAP.
|
static String |
getNameInSpaceForUsernameFromLDAP(String userName,
CommonLdapConfiguration ldapConfiguration,
DirContext dirContext)
This is to search user and retrieve ldap name directly from ldap.
|
static boolean |
isLdapsUrl(String url)
Check whether provided url is ldaps or not.
|
static boolean |
isNullOrEmptyAfterTrim(String str)
Checks whether a given string is null or empty after the trim.
|
static void |
removeServiceName() |
static void |
setServiceName(String serviceName) |
static String |
substituteVariables(String value)
Replace system property holders in the property values.
|
public static boolean isNullOrEmptyAfterTrim(String str)
str - String which needs to be check for null or emptypublic static String getNameInSpaceForUsernameFromLDAP(String userName, CommonLdapConfiguration ldapConfiguration, DirContext dirContext) throws UserStoreException, NamingException
userName - Given usernameldapConfiguration - LDAP user store configurationsdirContext - Directory naming contextUserStoreException - if there is any exception occurs during the processNamingException - if there is any exception occurs during the processpublic static String getNameInSpaceForUserName(String userName, String searchBase, String searchFilter, DirContext dirContext) throws UserStoreException, NamingException
userName - Given usernamesearchBase - LDAP search basesearchFilter - LDAP search filterdirContext - Directory naming contextUserStoreException - if there is any exception occurs during the processNamingException - if there is any exception occurs during the processpublic static Name escapeDNForSearch(String dn) throws InvalidNameException
dn - DNInvalidNameException - failed to build composite namepublic static void closeContext(DirContext dirContext) throws NamingException
dirContext - directory context needs be closedNamingException - if a naming exception is encounteredpublic static void closeNamingEnumeration(NamingEnumeration<?> namingEnumeration) throws NamingException
namingEnumeration - enumeration needs to be closedNamingException - if a naming exception is encounteredpublic static String escapeSpecialCharactersForFilter(String dnPartial)
dnPartial - String to replace special characters ofpublic static boolean isLdapsUrl(String url)
url - LDAP server urltrue if the url is an ldaps: url.public static String substituteVariables(String value)
value - string value to substitutepublic static String getInstanceIdFromThreadLocal()
public static void setServiceName(String serviceName)
public static void removeServiceName()
Copyright © 2019 WSO2. All rights reserved.