java.lang.Object
org.elasticsearch.xpack.security.authc.ldap.support.LdapSession
All Implemented Interfaces:
Closeable, AutoCloseable, org.elasticsearch.core.Releasable

public class LdapSession extends Object implements org.elasticsearch.core.Releasable
Represents a LDAP connection with an authenticated/bound user that needs closing.
  • Field Details

    • logger

      protected final org.apache.logging.log4j.Logger logger
    • realm

      protected final RealmConfig realm
    • connection

      protected final com.unboundid.ldap.sdk.LDAPInterface connection
    • userDn

      protected final String userDn
    • groupsResolver

      protected final LdapSession.GroupsResolver groupsResolver
    • timeout

      protected final org.elasticsearch.core.TimeValue timeout
    • attributes

      protected final Collection<com.unboundid.ldap.sdk.Attribute> 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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • userDn

      public String userDn()
      Returns:
      the fully distinguished name of the user bound to this connection
    • realm

      public RealmConfig 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

      public void groups(ActionListener<List<String>> listener)
      Asynchronously retrieves a list of group distinguished names
    • metadata

      public void metadata(ActionListener<LdapMetadataResolver.LdapMetadataResult> listener)
    • resolve

      public void resolve(ActionListener<LdapSession.LdapUserData> listener)