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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A GroupsResolver is used to resolve the group names of a given LDAP user
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Collection<com.unboundid.ldap.sdk.Attribute>
     
    protected final com.unboundid.ldap.sdk.LDAPInterface
     
     
    protected final org.apache.logging.log4j.Logger
     
    protected final org.elasticsearch.xpack.core.security.authc.RealmConfig
     
    protected final org.elasticsearch.core.TimeValue
     
    protected final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    LdapSession(org.apache.logging.log4j.Logger logger, org.elasticsearch.xpack.core.security.authc.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 Type
    Method
    Description
    void
    LDAP connections should be closed to clean up resources.
    com.unboundid.ldap.sdk.LDAPInterface
     
    void
    groups(org.elasticsearch.action.ActionListener<List<String>> listener)
    Asynchronously retrieves a list of group distinguished names
    void
    metadata(org.elasticsearch.action.ActionListener<Map<String,Object>> listener)
     
    org.elasticsearch.xpack.core.security.authc.RealmConfig
     
    void
    resolve(org.elasticsearch.action.ActionListener<LdapSession.LdapUserData> listener)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

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

      protected final org.elasticsearch.xpack.core.security.authc.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, org.elasticsearch.xpack.core.security.authc.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 org.elasticsearch.xpack.core.security.authc.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(org.elasticsearch.action.ActionListener<List<String>> listener)
      Asynchronously retrieves a list of group distinguished names
    • metadata

      public void metadata(org.elasticsearch.action.ActionListener<Map<String,Object>> listener)
    • resolve

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