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
 
 public class LDAPSession extends BaseSession This class represents a session against an LDAPDirectory.- Author:
- Olivier Grisel
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.nuxeo.ecm.directory.BaseSessionBaseSession.FieldDetector
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected DirContextdirContextprotected Set<String>emptySetprotected StringidAttributeprotected StringidCaseprotected static StringMISSING_ID_LOWER_CASEprotected static StringMISSING_ID_UPPER_CASEprotected StringpasswordHashAlgorithmprotected StringrdnAttributeprotected StringrdnFieldprotected StringsearchBaseDn- 
Fields inherited from class org.nuxeo.ecm.directory.BaseSessionautoincrementId, computeMultiTenantId, directory, directoryName, MULTI_TENANT_ID_FORMAT, permissions, POWER_USERS_GROUP, readAllColumns, READONLY_ENTRY_FLAG, referenceClass, schemaName, substringMatchType, TENANT_ID_FIELD
 
- 
 - 
Constructor SummaryConstructors Constructor Description LDAPSession(LDAPDirectory directory)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanauthenticate(String username, String password)Checks that the credentials provided by the UserManager match those registered in the directory.protected StringchangeEntryIdCase(String id, String idFieldCase)voidclose()Closes the session and all open result sets obtained from this session.DocumentModelcreateEntry(DocumentModel entry)Creates an entry in a directory.protected DocumentModelcreateEntryWithoutReferences(Map<String,Object> fieldMap)To be implemented for specific creation.voiddeleteEntry(String id, Map<String,String> map)Deletes a directory entry by id and secondary ids.voiddeleteEntryWithoutReferences(String id)To be implemented for specific deletion.protected DocumentModelfieldMapToDocumentModel(Map<String,Object> fieldMap)protected AttributegetAttributeValue(String fieldName, Object value)DirContextgetContext()LDAPDirectorygetDirectory()To be implemented with a more specific return type.DocumentModelgetEntryFromSource(String id, boolean fetchReferences)protected ObjectgetFieldValue(Attribute attribute, String fieldName, String entryId, boolean fetchReferences)protected SearchResultgetLdapEntry(String id)protected SearchResultgetLdapEntry(String id, boolean fetchAllAttributes)protected List<String>getMandatoryAttributes()protected List<String>getMandatoryAttributes(Attribute objectClassesAttribute)protected voidhandleException(Exception e, String message)booleanhasEntry(String id)Returns true if session has an entry with given id.booleanisAuthenticating()Tells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).protected DocumentModelListldapResultsToDocumentModels(NamingEnumeration<SearchResult> results, boolean fetchReferences)protected DocumentModelldapResultToDocumentModel(SearchResult result, String entryId, boolean fetchReferences)DocumentModelListquery(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.DocumentModelListquery(QueryBuilder queryBuilder, boolean fetchReferences)Executes a query with the possibility to fetch a subset of the results.List<String>queryIds(QueryBuilder queryBuilder)Executes a query with the possibility to fetch a subset of the results.booleanrdnMatchesIdField()StringtoString()protected List<String>updateEntryWithoutReferences(DocumentModel docModel)To be implemented for specific update.- 
Methods inherited from class org.nuxeo.ecm.directory.BaseSessionaddTenantId, applyQueryLimits, applyQueryLimits, canDeleteMultiTenantEntry, checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntry, createEntryModel, createEntryModel, createEntryModel, createEntryModel, createEntryModel, deleteEntry, deleteEntry, getCurrentTenantId, getEntries, getEntry, getEntry, getIdField, getPasswordField, getProjection, getProjection, hasPermission, hasPermission, isMultiTenant, isReadOnly, isReadOnlyEntry, query, query, query, query, setReadAllColumns, setReadOnlyEntry, setReadWriteEntry, toStringList, updateEntry
 
- 
 
- 
- 
- 
Field Detail- 
MISSING_ID_LOWER_CASEprotected static final String MISSING_ID_LOWER_CASE - See Also:
- Constant Field Values
 
 - 
MISSING_ID_UPPER_CASEprotected static final String MISSING_ID_UPPER_CASE - See Also:
- Constant Field Values
 
 - 
dirContextprotected DirContext dirContext 
 - 
idAttributeprotected final String idAttribute 
 - 
idCaseprotected final String idCase 
 - 
searchBaseDnprotected final String searchBaseDn 
 - 
rdnAttributeprotected final String rdnAttribute 
 - 
rdnFieldprotected final String rdnField 
 - 
passwordHashAlgorithmprotected final String passwordHashAlgorithm 
 
- 
 - 
Constructor Detail- 
LDAPSessionpublic LDAPSession(LDAPDirectory directory) 
 
- 
 - 
Method Detail- 
getDirectorypublic LDAPDirectory getDirectory() Description copied from class:BaseSessionTo be implemented with a more specific return type.- Specified by:
- getDirectoryin class- BaseSession
 
 - 
getContextpublic DirContext getContext() 
 - 
createEntryWithoutReferencesprotected DocumentModel createEntryWithoutReferences(Map<String,Object> fieldMap) Description copied from class:BaseSessionTo be implemented for specific creation.- Specified by:
- createEntryWithoutReferencesin class- BaseSession
 
 - 
updateEntryWithoutReferencesprotected List<String> updateEntryWithoutReferences(DocumentModel docModel) Description copied from class:BaseSessionTo be implemented for specific update.- Specified by:
- updateEntryWithoutReferencesin class- BaseSession
 
 - 
deleteEntryWithoutReferencespublic void deleteEntryWithoutReferences(String id) Description copied from class:BaseSessionTo be implemented for specific deletion.- Specified by:
- deleteEntryWithoutReferencesin class- BaseSession
 
 - 
hasEntrypublic boolean hasEntry(String id) Description copied from interface:SessionReturns true if session has an entry with given id.
 - 
getLdapEntryprotected SearchResult getLdapEntry(String id) throws NamingException - Throws:
- NamingException
 
 - 
getLdapEntryprotected SearchResult getLdapEntry(String id, boolean fetchAllAttributes) throws NamingException - Throws:
- NamingException
 
 - 
deleteEntrypublic void deleteEntry(String id, Map<String,String> map) Description copied from interface:SessionDeletes a directory entry by id and secondary ids.This is used for hierarchical vocabularies, where the actual unique key is the couple (parent, id). - Specified by:
- deleteEntryin interface- Session
- Overrides:
- deleteEntryin class- BaseSession
- Parameters:
- id- the id of the entry to delete.
- map- a map of secondary key values.
 
 - 
getEntryFromSourcepublic DocumentModel getEntryFromSource(String id, boolean fetchReferences) - Specified by:
- getEntryFromSourcein interface- EntrySource
- Overrides:
- getEntryFromSourcein class- BaseSession
 
 - 
querypublic DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences, int limit, int offset) Description copied from interface:SessionExecutes 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:
- Session.query(Map, Set, Map, boolean)
 
 - 
querypublic DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences) Description copied from interface:SessionExecutes 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
 
 - 
queryIdspublic List<String> queryIds(QueryBuilder queryBuilder) Description copied from interface:SessionExecutes 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
 
 - 
closepublic void close() Description copied from interface:SessionCloses 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? 
 - 
fieldMapToDocumentModelprotected DocumentModel fieldMapToDocumentModel(Map<String,Object> fieldMap) 
 - 
getFieldValueprotected Object getFieldValue(Attribute attribute, String fieldName, String entryId, boolean fetchReferences) 
 - 
ldapResultsToDocumentModelsprotected DocumentModelList ldapResultsToDocumentModels(NamingEnumeration<SearchResult> results, boolean fetchReferences) throws NamingException - Throws:
- NamingException
 
 - 
ldapResultToDocumentModelprotected DocumentModel ldapResultToDocumentModel(SearchResult result, String entryId, boolean fetchReferences) throws NamingException - Throws:
- NamingException
 
 - 
authenticatepublic boolean authenticate(String username, String password) Description copied from interface:SessionChecks 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
 
 - 
isAuthenticatingpublic boolean isAuthenticating() Description copied from interface:SessionTells whether the directory implementation can be used as an authenticating backend for the UserManager (based on login / password check).- Specified by:
- isAuthenticatingin interface- Session
- Overrides:
- isAuthenticatingin class- BaseSession
- Returns:
- true is the directory is authentication aware
 
 - 
rdnMatchesIdFieldpublic boolean rdnMatchesIdField() 
 - 
getMandatoryAttributesprotected List<String> getMandatoryAttributes(Attribute objectClassesAttribute) 
 - 
createEntrypublic DocumentModel createEntry(DocumentModel entry) Description copied from interface:SessionCreates an entry in a directory.- Specified by:
- createEntryin interface- Session
- Overrides:
- createEntryin class- BaseSession
- Parameters:
- entry- the document model representing the entry to create
- Returns:
- The new entry created in the directory
 
 
- 
 
-