Class LdapNetworkConnector<C>
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.util.net.NetworkConnector
org.apache.sshd.ldap.LdapNetworkConnector<C>
- Type Parameters:
C- Type of context being passed toresolveAttributes(String, String, Object)
- Direct Known Subclasses:
LdapAuthenticator
public class LdapNetworkConnector<C>
extends org.apache.sshd.common.util.net.NetworkConnector
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanstatic final StringA special value used to indicate that all attributes are requiredprotected MessageFormatprotected MessageFormatprotected MessageFormatstatic final StringA list of known binary attributesstatic final booleanstatic final Stringstatic final Stringstatic final longstatic final booleanstatic final StringProperty used to override the default LDAP context factory classstatic final StringDefault LDAP context factory class - unless overridden via theDEFAULT_LDAP_FACTORY_PROPNAMEpropertystatic final intstatic final Stringstatic final Stringstatic final booleanstatic final intstatic final longprotected final SearchControlsprotected MessageFormatFields inherited from class org.apache.sshd.common.util.net.NetworkConnector
DEFAULT_CONNECT_TIMEOUT, DEFAULT_HOST, DEFAULT_READ_TIMEOUTFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectaccumulateAttributeValue(C queryContext, Map<String, Object> attrsMap, String attrID, Object attrVal) longintintlongprotected DirContextbooleanbooleanbooleanprotected ObjectprocessResultAttributeValue(C queryContext, Map<?, ?> ldapConfig, String dn, int resultIndex, Map<String, Object> attrsMap, Attribute a) protected voidprocessSearchResult(C queryContext, Map<?, ?> ldapConfig, Map<String, Object> attrsMap, int resultIndex, SearchResult result) queryAttributes(C queryContext, DirContext context, Map<?, ?> ldapConfig, String username, String password) resolveAttributes(String username, String password, C queryContext) protected StringresolveBaseDN(C queryContext, Map<?, ?> ldapConfig, String username, String password) protected StringresolveSearchFilter(C queryContext, Map<?, ?> ldapConfig, String username, String password) voidsetAccumulateMultiValues(boolean enabled) voidsetAuthenticationMode(String mode) voidvoidsetBinaryAttributes(String value) voidvoidvoidsetConnectTimeout(long connectTimeout) voidsetCountLimit(long count) voidsetDerefLink(boolean enabled) voidsetLdapFactory(String factory) voidsetProtocolVersion(int value) voidsetReadTimeout(long readTimeout) voidsetReferralMode(String mode) voidsetRetrievedAttributes(String attrs) voidsetReturningObjFlag(boolean enabled) voidvoidsetSearchScope(int scope) voidsetTimeLimit(long limit) setupDirContextEnvironment(C queryContext, Map<String, Object> env, String username, String password) Called in order to set up the environment configuration passed to theInitialDirContext(Hashtable)constructorstatic StringMethods inherited from class org.apache.sshd.common.util.net.NetworkConnector
getConnectTimeout, getHost, getPort, getProtocol, getReadTimeout, setHost, setPort, setProtocol, toStringMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Field Details
-
DEFAULT_LDAP_PROTOCOL
- See Also:
-
DEFAULT_LDAP_PORT
public static final int DEFAULT_LDAP_PORT- See Also:
-
DEFAULT_LDAP_FACTORY_PROPNAME
Property used to override the default LDAP context factory class- See Also:
-
DEFAULT_LDAP_FACTORY_PROPVAL
Default LDAP context factory class - unless overridden via theDEFAULT_LDAP_FACTORY_PROPNAMEproperty- See Also:
-
DEFAULT_LDAP_SEARCH_SCOPE
public static final int DEFAULT_LDAP_SEARCH_SCOPE- See Also:
-
DEFAULT_LDAP_TIME_LIMIT
public static final long DEFAULT_LDAP_TIME_LIMIT -
DEFAULT_LDAP_REFERRAL_MODE
- See Also:
-
DEFAULT_LDAP_COUNT_LIMIT
public static final long DEFAULT_LDAP_COUNT_LIMIT- See Also:
-
DEFAULT_LDAP_DEREF_ENABLED
public static final boolean DEFAULT_LDAP_DEREF_ENABLED- See Also:
-
ALL_LDAP_ATTRIBUTES
A special value used to indicate that all attributes are required- See Also:
-
DEFAULT_LDAP_RETURN_OBJVALUE
public static final boolean DEFAULT_LDAP_RETURN_OBJVALUE- See Also:
-
DEFAULT_LDAP_ACCUMULATE_MULTIVALUES
public static final boolean DEFAULT_LDAP_ACCUMULATE_MULTIVALUES- See Also:
-
DEFAULT_LDAP_BIND_DN_PATTERN
- See Also:
-
DEFAULT_LDAP_BIND_PASSWORD_PATTERN
- See Also:
-
DEFAULT_BINARY_ATTRIBUTES
-
searchControls
-
ldapEnv
-
bindDNPattern
-
bindPasswordPattern
-
searchFilterPattern
-
baseDNPattern
-
accumulateMultiValues
private boolean accumulateMultiValues
-
-
Constructor Details
-
LdapNetworkConnector
public LdapNetworkConnector()
-
-
Method Details
-
setConnectTimeout
public void setConnectTimeout(long connectTimeout) - Overrides:
setConnectTimeoutin classorg.apache.sshd.common.util.net.NetworkConnector
-
setReadTimeout
public void setReadTimeout(long readTimeout) - Overrides:
setReadTimeoutin classorg.apache.sshd.common.util.net.NetworkConnector
-
getLdapFactory
-
setLdapFactory
- Parameters:
factory- The LDAP context factory
-
getBaseDN
-
setBaseDN
- Parameters:
p- The base DN pattern - the arguments to the pattern depend on the actual usage- See Also:
-
getBindDNPattern
-
setBindDNPattern
-
getBindPasswordPattern
-
setBindPasswordPattern
-
getSearchFilterPattern
-
setSearchFilterPattern
-
getSearchScope
public int getSearchScope()- Returns:
- The search scope
- See Also:
-
setSearchScope
public void setSearchScope(int scope) - Parameters:
scope- The search scope- See Also:
-
getTimeLimit
public long getTimeLimit()- Returns:
- Time limit (millis) to wait for result - zero means forever
-
setTimeLimit
public void setTimeLimit(long limit) -
getCountLimit
public long getCountLimit()- Returns:
- Maximum number of entries to be returned in a query
-
setCountLimit
public void setCountLimit(long count) -
isDerefLink
public boolean isDerefLink()- Returns:
truewhether links should be de-referenced- See Also:
-
setDerefLink
public void setDerefLink(boolean enabled) -
getRetrievedAttributes
- Returns:
- Comma separated list of attributes to retrieve
-
setRetrievedAttributes
- Parameters:
attrs- Comma separated list of attributes to retrieve - ifnull/empty then no attributes are retrieved- See Also:
-
isAccumulateMultiValues
public boolean isAccumulateMultiValues() -
setAccumulateMultiValues
public void setAccumulateMultiValues(boolean enabled) -
isReturningObjFlag
public boolean isReturningObjFlag()- Returns:
trueif objects are returned as result of the query- See Also:
-
setReturningObjFlag
public void setReturningObjFlag(boolean enabled) -
getAuthenticationMode
- Returns:
- Authentication mode to use: &qout;none", "simple", etc.
- See Also:
-
setAuthenticationMode
-
getReferralMode
- Returns:
- How referrals encountered by the service provider are to be processed
- See Also:
-
setReferralMode
-
getProtocolVersion
public int getProtocolVersion()- Returns:
- The specified protocol version - non-positive if default provider version used
-
setProtocolVersion
public void setProtocolVersion(int value) -
getBinaryAttributes
- Returns:
- Comma separated list of attributes known to be binary so that they are returned as
byte[]value rather than strings
-
setBinaryAttributes
- Parameters:
value- Comma separated list of attributes known to be binary so that they are returned asbyte[]value rather than strings- See Also:
-
resolveAttributes
public Map<String,Object> resolveAttributes(String username, String password, C queryContext) throws NamingException - Parameters:
username- Username to be used either to access the LDAP or retrieve the user's attributes - may benull/empty if not required for the specific querypassword- Password Password to be used if necessary - may benull/empty if not required for the specific queryqueryContext- User specific query context - relevant for derived classes that want to override some of query processing methods- Returns:
- A
Mapof the retrieved attributes - Note: ifisAccumulateMultiValues()istrueand multiple values are encountered for an attribute then aListof them is mapped as its value - Throws:
NamingException- If failed to executed the LDAP query- See Also:
-
queryAttributes
protected Map<String,Object> queryAttributes(C queryContext, DirContext context, Map<?, ?> ldapConfig, String username, String password) throws NamingException- Parameters:
queryContext- The user-specific query contextcontext- The initializedDirContextldapConfig- The LDAP environment setupusername- The usernamepassword- The password- Returns:
- A
Mapof the retrieved attributes - Note: ifisAccumulateMultiValues()istrueand multiple values are encountered for an attribute then aListof them is mapped as its value - Throws:
NamingException- If failed to executed the LDAP query
-
initializeDirContext
protected DirContext initializeDirContext(C queryContext, Map<String, Object> env, String username, String password) throws NamingException- Throws:
NamingException
-
setupDirContextEnvironment
protected Map<String,Object> setupDirContextEnvironment(C queryContext, Map<String, Object> env, String username, String password) throws NamingExceptionCalled in order to set up the environment configuration passed to theInitialDirContext(Hashtable)constructor- Parameters:
queryContext- The caller-specific query contextenv- The current environment setupusername- The username - may benull/emptypassword- The password - may benull/empty- Returns:
- An updated environment configuration - can be a new instance or just the original one with some changes in it
- Throws:
NamingException- If failed to set up the environment
-
resolveBaseDN
protected String resolveBaseDN(C queryContext, Map<?, ?> ldapConfig, String username, String password) throws NamingException- Throws:
NamingException
-
resolveSearchFilter
protected String resolveSearchFilter(C queryContext, Map<?, ?> ldapConfig, String username, String password) throws NamingException- Throws:
NamingException
-
processSearchResult
protected void processSearchResult(C queryContext, Map<?, ?> ldapConfig, Map<String, throws NamingExceptionObject> attrsMap, int resultIndex, SearchResult result) - Throws:
NamingException
-
processResultAttributeValue
protected Object processResultAttributeValue(C queryContext, Map<?, ?> ldapConfig, String dn, int resultIndex, Map<String, throws NamingExceptionObject> attrsMap, Attribute a) - Throws:
NamingException
-
accumulateAttributeValue
-
toString
-