Package org.nuxeo.ecm.directory.ldap
Class LDAPSession
java.lang.Object
org.nuxeo.ecm.directory.BaseSession
org.nuxeo.ecm.directory.ldap.LDAPSession
- All Implemented Interfaces:
AutoCloseable
,EntrySource
,Session
This class represents a session against an LDAPDirectory.
- Author:
- Olivier Grisel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.nuxeo.ecm.directory.BaseSession
BaseSession.FieldDetector
-
Field Summary
Modifier and TypeFieldDescriptionprotected DirContext
protected final String
protected final String
protected static final String
protected static final String
protected final String
protected final String
protected final String
protected final String
Fields inherited from class org.nuxeo.ecm.directory.BaseSession
autoincrementId, computeMultiTenantId, directory, directoryName, MULTI_TENANT_ID_FORMAT, permissions, POWER_USERS_GROUP, readAllColumns, READONLY_ENTRY_FLAG, referenceClass, schemaName, substringMatchType, TENANT_ID_FIELD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
authenticate
(String username, String password) Checks that the credentials provided by the UserManager match those registered in the directory.protected String
changeEntryIdCase
(String id, String idFieldCase) void
close()
Closes the session and all open result sets obtained from this session.createEntry
(DocumentModel entry) Creates an entry in a directory.protected DocumentModel
createEntryWithoutReferences
(Map<String, Object> fieldMap) To be implemented for specific creation.void
To be implemented for specific deletion.protected DocumentModel
fieldMapToDocumentModel
(Map<String, Object> fieldMap) protected Attribute
getAttributeValue
(String fieldName, Object value) To be implemented with a more specific return type.getEntryFromSource
(String id, boolean fetchReferences) protected Object
getFieldValue
(Attribute attribute, String fieldName, String entryId, boolean fetchReferences) protected SearchResult
getLdapEntry
(String id) protected SearchResult
getLdapEntry
(String id, boolean fetchAllAttributes) getMandatoryAttributes
(Attribute objectClassesAttribute) protected void
handleException
(Exception e, String message) boolean
Returns true if session has an entry with given id.boolean
Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).protected DocumentModelList
ldapResultsToDocumentModels
(NamingEnumeration<SearchResult> results, boolean fetchReferences) protected DocumentModel
ldapResultToDocumentModel
(SearchResult result, String entryId, boolean fetchReferences) query
(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy, boolean fetchReferences, int limit, int offset) 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.query
(QueryBuilder queryBuilder, boolean fetchReferences) Executes a query with the possibility to fetch a subset of the results.queryIds
(QueryBuilder queryBuilder) Executes a query with the possibility to fetch a subset of the results.boolean
toString()
updateEntryWithoutReferences
(DocumentModel docModel) To be implemented for specific update.Methods inherited from class org.nuxeo.ecm.directory.BaseSession
addTenantId, applyQueryLimits, applyQueryLimits, canDeleteMultiTenantEntry, checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, deleteEntry, deleteEntry, getCurrentTenantId, getEntry, getEntry, getIdField, getPasswordField, getProjection, getProjection, hasPermission, hasPermission, isMultiTenant, isReadOnly, isReadOnlyEntry, query, query, query, query, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, toStringList, updateEntry
-
Field Details
-
MISSING_ID_LOWER_CASE
- See Also:
-
MISSING_ID_UPPER_CASE
- See Also:
-
dirContext
-
idAttribute
-
idCase
-
searchBaseDn
-
emptySet
-
rdnAttribute
-
rdnField
-
passwordHashAlgorithm
-
-
Constructor Details
-
LDAPSession
-
-
Method Details
-
getDirectory
Description copied from class:BaseSession
To be implemented with a more specific return type.- Specified by:
getDirectory
in classBaseSession
-
getContext
-
createEntryWithoutReferences
Description copied from class:BaseSession
To be implemented for specific creation.- Specified by:
createEntryWithoutReferences
in classBaseSession
-
updateEntryWithoutReferences
Description copied from class:BaseSession
To be implemented for specific update.- Specified by:
updateEntryWithoutReferences
in classBaseSession
-
deleteEntryWithoutReferences
Description copied from class:BaseSession
To be implemented for specific deletion.- Specified by:
deleteEntryWithoutReferences
in classBaseSession
-
hasEntry
Description copied from interface:Session
Returns true if session has an entry with given id. -
getLdapEntry
- Throws:
NamingException
-
getLdapEntry
- Throws:
NamingException
-
handleException
-
getEntryFromSource
- Specified by:
getEntryFromSource
in interfaceEntrySource
- Overrides:
getEntryFromSource
in classBaseSession
-
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 1offset
- number of rows skipped before starting, will be 0 if less than 0.- See Also:
-
query
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 countTotalfetchReferences
- 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
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
-
getFieldValue
-
getAttributeValue
-
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
-
authenticate
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 interfaceSession
- Overrides:
isAuthenticating
in classBaseSession
- Returns:
- true is the directory is authentication aware
-
rdnMatchesIdField
public boolean rdnMatchesIdField() -
getMandatoryAttributes
-
getMandatoryAttributes
-
toString
-
createEntry
Description copied from interface:Session
Creates an entry in a directory.- Specified by:
createEntry
in interfaceSession
- Overrides:
createEntry
in classBaseSession
- Parameters:
entry
- the document model representing the entry to create- Returns:
- The new entry created in the directory
-