Class LDAPSession

java.lang.Object
org.nuxeo.ecm.directory.BaseSession
org.nuxeo.ecm.directory.ldap.LDAPSession
All Implemented Interfaces:
AutoCloseable, EntrySource, Session

public class LDAPSession extends BaseSession
This class represents a session against an LDAPDirectory.
Author:
Olivier Grisel
  • Field Details

    • MISSING_ID_LOWER_CASE

      protected static final String MISSING_ID_LOWER_CASE
      See Also:
    • MISSING_ID_UPPER_CASE

      protected static final String MISSING_ID_UPPER_CASE
      See Also:
    • dirContext

      protected DirContext dirContext
    • idAttribute

      protected final String idAttribute
    • idCase

      protected final String idCase
    • searchBaseDn

      protected final String searchBaseDn
    • emptySet

      protected final Set<String> emptySet
    • rdnAttribute

      protected final String rdnAttribute
    • rdnField

      protected final String rdnField
    • passwordHashAlgorithm

      protected final String passwordHashAlgorithm
  • Constructor Details

  • Method Details

    • getDirectory

      public LDAPDirectory getDirectory()
      Description copied from class: BaseSession
      To be implemented with a more specific return type.
      Specified by:
      getDirectory in class BaseSession
    • getContext

      public DirContext getContext()
    • createEntryWithoutReferences

      protected DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap)
      Description copied from class: BaseSession
      To be implemented for specific creation.
      Specified by:
      createEntryWithoutReferences in class BaseSession
    • updateEntryWithoutReferences

      protected List<String> updateEntryWithoutReferences(DocumentModel docModel)
      Description copied from class: BaseSession
      To be implemented for specific update.
      Specified by:
      updateEntryWithoutReferences in class BaseSession
    • deleteEntryWithoutReferences

      public void deleteEntryWithoutReferences(String id)
      Description copied from class: BaseSession
      To be implemented for specific deletion.
      Specified by:
      deleteEntryWithoutReferences in class BaseSession
    • hasEntry

      public boolean hasEntry(String id)
      Description copied from interface: Session
      Returns true if session has an entry with given id.
    • getLdapEntry

      protected SearchResult getLdapEntry(String id) throws NamingException
      Throws:
      NamingException
    • getLdapEntry

      protected SearchResult getLdapEntry(String id, boolean fetchAllAttributes) throws NamingException
      Throws:
      NamingException
    • handleException

      protected void handleException(Exception e, String message)
    • getEntryFromSource

      public DocumentModel getEntryFromSource(String id, boolean fetchReferences)
      Specified by:
      getEntryFromSource in interface EntrySource
      Overrides:
      getEntryFromSource in class BaseSession
    • query

      public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset)
      Description copied from interface: Session
      Executes a query with the possibility to fetch a subset of the results. org.nuxeo.ecm.directory.BaseSession provides a default implementation fetching all results to return the subset. Not recommended.
      limit - maximum number of results ignored if less than 1
      offset - number of rows skipped before starting, will be 0 if less than 0.
      See Also:
    • query

      public DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences)
      Description copied from interface: Session
      Executes a query with the possibility to fetch a subset of the results.
      Parameters:
      queryBuilder - the query to use, including limit, offset, ordering and countTotal
      fetchReferences - boolean stating if references have to be fetched
      Returns:
      the list of documents, where the total size may be present if countTotal was true
    • queryIds

      public List<String> queryIds(QueryBuilder queryBuilder)
      Description copied from interface: Session
      Executes a query with the possibility to fetch a subset of the results. Returns the matching ids.
      Parameters:
      queryBuilder - the query to use, including limit, offset and ordering
      Returns:
      the list of document ids
    • close

      public void close()
      Description copied from interface: Session
      Closes the session and all open result sets obtained from this session.

      Releases this Connection object's resources immediately instead of waiting for them to be automatically released.

      TODO: should this operation auto-commit pending changes?

    • fieldMapToDocumentModel

      protected DocumentModel fieldMapToDocumentModel(Map<String,Object> fieldMap)
    • getFieldValue

      protected Object getFieldValue(Attribute attribute, String fieldName, String entryId, boolean fetchReferences)
    • getAttributeValue

      protected Attribute getAttributeValue(String fieldName, Object value)
    • ldapResultsToDocumentModels

      protected DocumentModelList ldapResultsToDocumentModels(NamingEnumeration<SearchResult> results, boolean fetchReferences) throws NamingException
      Throws:
      NamingException
    • ldapResultToDocumentModel

      protected DocumentModel ldapResultToDocumentModel(SearchResult result, String entryId, boolean fetchReferences) throws NamingException
      Throws:
      NamingException
    • changeEntryIdCase

      protected String changeEntryIdCase(String id, String idFieldCase)
    • authenticate

      public boolean authenticate(String username, String password)
      Description copied from interface: Session
      Checks that the credentials provided by the UserManager match those registered in the directory. If username is not in the directory, this should return false instead of throrwing an exception.
      Returns:
      true is the credentials match those stored in the directory
    • isAuthenticating

      public boolean isAuthenticating()
      Description copied from interface: Session
      Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).
      Specified by:
      isAuthenticating in interface Session
      Overrides:
      isAuthenticating in class BaseSession
      Returns:
      true is the directory is authentication aware
    • rdnMatchesIdField

      public boolean rdnMatchesIdField()
    • getMandatoryAttributes

      protected List<String> getMandatoryAttributes(Attribute objectClassesAttribute)
    • getMandatoryAttributes

      protected List<String> getMandatoryAttributes()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createEntry

      public DocumentModel createEntry(DocumentModel entry)
      Description copied from interface: Session
      Creates an entry in a directory.
      Specified by:
      createEntry in interface Session
      Overrides:
      createEntry in class BaseSession
      Parameters:
      entry - the document model representing the entry to create
      Returns:
      The new entry created in the directory