Module org.elasticsearch.security
Class LdapSession
java.lang.Object
org.elasticsearch.xpack.security.authc.ldap.support.LdapSession
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.elasticsearch.core.Releasable
Represents a LDAP connection with an authenticated/bound user that needs closing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A GroupsResolver is used to resolve the group names of a given LDAP userstatic class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection
<com.unboundid.ldap.sdk.Attribute> protected final com.unboundid.ldap.sdk.LDAPInterface
protected final LdapSession.GroupsResolver
protected final org.apache.logging.log4j.Logger
protected final RealmConfig
protected final org.elasticsearch.core.TimeValue
protected final String
-
Constructor Summary
ConstructorsConstructorDescriptionLdapSession
(org.apache.logging.log4j.Logger logger, RealmConfig realm, com.unboundid.ldap.sdk.LDAPInterface connection, String userDn, LdapSession.GroupsResolver groupsResolver, LdapMetadataResolver metadataResolver, org.elasticsearch.core.TimeValue timeout, Collection<com.unboundid.ldap.sdk.Attribute> attributes) This object is intended to be constructed by the LdapConnectionFactory This constructor accepts a logger with which the connection can log. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
LDAP connections should be closed to clean up resources.com.unboundid.ldap.sdk.LDAPInterface
void
groups
(ActionListener<List<String>> listener) Asynchronously retrieves a list of group distinguished namesvoid
realm()
void
resolve
(ActionListener<LdapSession.LdapUserData> listener) userDn()
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
realm
-
connection
protected final com.unboundid.ldap.sdk.LDAPInterface connection -
userDn
-
groupsResolver
-
timeout
protected final org.elasticsearch.core.TimeValue timeout -
attributes
-
-
Constructor Details
-
LdapSession
public LdapSession(org.apache.logging.log4j.Logger logger, RealmConfig realm, com.unboundid.ldap.sdk.LDAPInterface connection, String userDn, LdapSession.GroupsResolver groupsResolver, LdapMetadataResolver metadataResolver, org.elasticsearch.core.TimeValue timeout, Collection<com.unboundid.ldap.sdk.Attribute> attributes) This object is intended to be constructed by the LdapConnectionFactory This constructor accepts a logger with which the connection can log. Since this connection can be instantiated very frequently, it's best to have the logger for this connection created outside of and be reused across all connections. We can't keep a static logger in this class since we want the logger to be contextual (i.e. aware of the settings and its environment).
-
-
Method Details
-
close
public void close()LDAP connections should be closed to clean up resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.elasticsearch.core.Releasable
-
userDn
- Returns:
- the fully distinguished name of the user bound to this connection
-
realm
- Returns:
- the realm for which this session was created
-
getConnection
public com.unboundid.ldap.sdk.LDAPInterface getConnection()- Returns:
- the connection to the LDAP/AD server of this session
-
groups
Asynchronously retrieves a list of group distinguished names -
metadata
-
resolve
-