Class ObservationContextSource

java.lang.Object
org.springframework.ldap.core.support.ObservationContextSource
All Implemented Interfaces:
ContextSource, BaseLdapPathContextSource, BaseLdapPathSource

public final class ObservationContextSource extends Object implements BaseLdapPathContextSource
An implementation of ContextSource that returns DirContext instances that record the time each operation takes.
Since:
3.3
  • Constructor Details

    • ObservationContextSource

      public ObservationContextSource(BaseLdapPathContextSource contextSource, io.micrometer.observation.ObservationRegistry observationRegistry)
  • Method Details

    • getReadOnlyContext

      public DirContext getReadOnlyContext() throws NamingException
      Description copied from interface: ContextSource
      Gets a read-only DirContext. The returned DirContext must be possible to perform read-only operations on.
      Specified by:
      getReadOnlyContext in interface ContextSource
      Returns:
      A DirContext instance, never null.
      Throws:
      NamingException - if some error occurs creating an DirContext.
    • getReadWriteContext

      public DirContext getReadWriteContext() throws NamingException
      Description copied from interface: ContextSource
      Gets a read-write DirContext instance.
      Specified by:
      getReadWriteContext in interface ContextSource
      Returns:
      A DirContext instance, never null.
      Throws:
      NamingException - if some error occurs creating an DirContext.
    • getContext

      public DirContext getContext(String principal, String credentials) throws NamingException
      Description copied from interface: ContextSource
      Gets a DirContext instance authenticated using the supplied principal and credentials. Typically to be used for plain authentication purposes. Note that this method will never make use of native Java LDAP pooling, even though this instance is configured to do so. This is to force password changes in the target directory to take effect as soon as possible.
      Specified by:
      getContext in interface ContextSource
      Parameters:
      principal - The principal (typically a distinguished name of a user in the LDAP tree) to use for authentication.
      credentials - The credentials to use for authentication.
      Returns:
      an authenticated DirContext instance, never null.
      Throws:
      NamingException
    • getBaseLdapPath

      @Deprecated public DistinguishedName getBaseLdapPath()
      Deprecated.
      Description copied from interface: BaseLdapPathSource
      Get the base LDAP path as a DistinguishedName.
      Specified by:
      getBaseLdapPath in interface BaseLdapPathSource
      Returns:
      the base LDAP path as a DistinguishedName. The path will be empty if no base path is specified.
    • getBaseLdapName

      public LdapName getBaseLdapName()
      Description copied from interface: BaseLdapPathSource
      Get the base LDAP path as a LdapName.
      Specified by:
      getBaseLdapName in interface BaseLdapPathSource
      Returns:
      the base LDAP path as a LdapName. The path will be empty if no base path is specified.
    • getBaseLdapPathAsString

      public String getBaseLdapPathAsString()
      Description copied from interface: BaseLdapPathSource
      Get the base LDAP path as a String.
      Specified by:
      getBaseLdapPathAsString in interface BaseLdapPathSource
      Returns:
      the base LDAP path as a An empty String will be returned if no base path is specified.