Class LDAPHelper
java.lang.Object
com.inductiveautomation.ignition.gateway.authentication.impl.LDAPHelper
Encapsulates lots of the boilerplate code required to connect to and query an LDAP server.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enumstatic interface
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidcloseQuietly(DirContext ctx) intbooleanbooleanbooleanisUserValid(String uname, String pwd) Checks the validity of a username/password pair against the ldap serverbooleanisUseSSL()openContext(String uname, String pwd) Opens an LDAP query context with the given username and password.static String[]parseBasePatternString(String basePatternString) Given a string containing LDAP patterns for user locations (separated by parentheses in a pseudo-LDAP search string format - "(location1)(location2)", returns an array of those paths.<T> List<T>search(String[] bases, String filter, Object[] filterArgs, LDAPHelper.SearchHandler<T> handler) Opens a context using the profile username/password.<T> List<T>search(LdapContext ctx, String[] bases, String filter, Object[] filterArgs, SearchControls controls, LDAPHelper.SearchHandler<T> handler) Searches using the filter and args on each base specified on the supplied context.voidsetAllowAnon(boolean allowAnon) voidsetLdapHost(String ldapHost) voidsetLdapPort(String ldapPort) voidsetPageSize(int size) voidsetProfilePassword(String profilePassword) voidsetProfileUsername(String profileUsername) voidsetReadTimeout(Long readTimeout) voidsetReferral(LDAPHelper.ReferralType referral) voidsetSaslConfig(SASLConfig saslConfig) voidsetSecondaryLdapHost(String secondaryLdapHost) voidsetSecondaryLdapPort(String secondaryLdapPort) voidsetSecurityAuthentication(LDAPHelper.AuthType securityAuthentication) voidsetSecurityProtocol(LDAPHelper.ProtocolType securityProtocol) voidsetUsePrefixAndSuffixForGatewayUser(boolean usePrefixAndSuffixForGatewayUser) voidsetUsernamePrefix(String usernamePrefix) voidsetUsernameSuffix(String usernameSuffix) voidsetUseSSL(boolean useSSL) 
- 
Constructor Details- 
LDAPHelper
 
- 
- 
Method Details- 
parseBasePatternStringGiven a string containing LDAP patterns for user locations (separated by parentheses in a pseudo-LDAP search string format - "(location1)(location2)", returns an array of those paths. Real LDAP search strings are supported as well (though only the "|" "OR" type).- Parameters:
- basePatternString- - a string LDAP search paths surrounded by parentheses
 
- 
openContextOpens an LDAP query context with the given username and password. Will never return null.- Throws:
- Exception
 
- 
closeQuietly
- 
isUserValidChecks the validity of a username/password pair against the ldap server- Throws:
- Exception
 
- 
searchpublic <T> List<T> search(String[] bases, String filter, Object[] filterArgs, LDAPHelper.SearchHandler<T> handler) throws Exception Opens a context using the profile username/password. Uses search scope SUBTREE_SCOPE.- Parameters:
- bases- An array of bases to search through. Each one is searched separately.
- filter- The filter string to use.
- filterArgs- The arguments for the filter (may be null if not applicable)
- handler- The handler to turn search results into useful objects.
- Throws:
- Exception
 
- 
searchpublic <T> List<T> search(LdapContext ctx, String[] bases, String filter, Object[] filterArgs, SearchControls controls, LDAPHelper.SearchHandler<T> handler) throws Exception Searches using the filter and args on each base specified on the supplied context. Will close the context afterwards.- Parameters:
- ctx- The directory context to search.
- bases- An array of bases to search through. Each one is searched separately.
- filter- The filter string to use.
- filterArgs- The arguments for the filter (may be null if not applicable)
- controls- The search controls.
- handler- The handler to turn search results into useful objects.
- Throws:
- Exception
 
- 
getLdapHost
- 
setLdapHost
- 
getLdapPort
- 
setLdapPort
- 
getSecondaryLdapHost
- 
setSecondaryLdapHost
- 
getSecondaryLdapPort
- 
setSecondaryLdapPort
- 
getUsernameSuffix
- 
setUsernameSuffix
- 
getUsernamePrefix
- 
setUsernamePrefix
- 
getProfileUsername
- 
setProfileUsername
- 
getProfilePassword
- 
setProfilePassword
- 
isUsePrefixAndSuffixForGatewayUserpublic boolean isUsePrefixAndSuffixForGatewayUser()
- 
setUsePrefixAndSuffixForGatewayUserpublic void setUsePrefixAndSuffixForGatewayUser(boolean usePrefixAndSuffixForGatewayUser) 
- 
setUseSSLpublic void setUseSSL(boolean useSSL) 
- 
isUseSSLpublic boolean isUseSSL()
- 
setAllowAnonpublic void setAllowAnon(boolean allowAnon) 
- 
isAllowAnonpublic boolean isAllowAnon()
- 
setSecurityAuthentication
- 
getSecurityAuthentication
- 
setSecurityProtocol
- 
getSecurityProtocol
- 
getReadTimeout
- 
setReadTimeout
- 
setPageSizepublic void setPageSize(int size) 
- 
getPageSizepublic int getPageSize()
- 
getSaslConfig
- 
setSaslConfig
- 
getReferral
- 
setReferral
 
-