public class LDAPSession extends BaseSession implements EntrySource
| Modifier and Type | Field and Description |
|---|---|
protected DirContext |
dirContext |
protected Set<String> |
emptySet |
protected String |
idAttribute |
protected String |
idCase |
protected static String |
MISSING_ID_LOWER_CASE |
protected static String |
MISSING_ID_UPPER_CASE |
protected String |
passwordHashAlgorithm |
protected String |
rdnAttribute |
protected String |
rdnField |
protected Map<String,Field> |
schemaFieldMap |
protected String |
schemaName |
protected String |
searchBaseDn |
protected String |
sid |
protected BaseDirectoryDescriptor.SubstringMatchType |
substringMatchType |
directory, MULTI_TENANT_ID_FORMAT, permissions, POWER_USERS_GROUP, READONLY_ENTRY_FLAG| Constructor and Description |
|---|
LDAPSession(LDAPDirectory directory,
DirContext dirContext) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
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.
|
DocumentModel |
createEntry(DocumentModel entry)
Creates an entry in a directory.
|
DocumentModel |
createEntry(Map<String,Object> fieldMap)
Creates an entry in a directory.
|
void |
deleteEntry(DocumentModel dm)
Deletes a directory entry.
|
void |
deleteEntry(String id)
Deletes a directory entry by id.
|
void |
deleteEntry(String id,
Map<String,String> map)
Deletes a directory entry by id and secondary ids.
|
protected DocumentModel |
fieldMapToDocumentModel(Map<String,Object> fieldMap) |
protected Attribute |
getAttributeValue(String fieldName,
Object value) |
DirContext |
getContext() |
LDAPDirectory |
getDirectory()
To be implemented with a more specific return type.
|
DocumentModelList |
getEntries()
Retrieves all the entries in the directory.
|
DocumentModel |
getEntry(String id)
Retrieves a directory entry using its id.
|
DocumentModel |
getEntry(String id,
boolean fetchReferences)
Retrieves a directory entry using its id.
|
DocumentModel |
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) |
protected List<String> |
getMandatoryAttributes() |
protected List<String> |
getMandatoryAttributes(Attribute objectClassesAttribute) |
List<String> |
getProjection(Map<String,Serializable> filter,
Set<String> fulltext,
String columnName) |
List<String> |
getProjection(Map<String,Serializable> filter,
String columnName)
Executes a query using filter and return only the column columnName.
|
protected void |
handleException(Exception e,
String message) |
boolean |
hasEntry(String id)
Returns true if session has an entry with given id.
|
boolean |
isAuthenticating()
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) |
DocumentModelList |
query(Map<String,Serializable> filter)
Executes a simple query.
|
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext)
Executes a simple query.
|
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext,
boolean fetchReferences,
Map<String,String> orderBy) |
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext,
Map<String,String> orderBy)
Executes a simple query.
|
DocumentModelList |
query(Map<String,Serializable> filter,
Set<String> fulltext,
Map<String,String> orderBy,
boolean fetchReferences)
Executes a query with the possibility to fetch references
|
boolean |
rdnMatchesIdField() |
String |
toString() |
void |
updateEntry(DocumentModel docModel)
Updates a directory entry.
|
checkDeleteConstraints, checkPermission, computeMultiTenantDirectoryId, createEntryModel, createEntryModel, getIdField, getPasswordField, hasPermission, hasPermission, isReadOnly, isReadOnlyEntry, mkObjectMap, mkSerializableMap, query, setReadOnlyEntry, setReadWriteEntryprotected static final String MISSING_ID_LOWER_CASE
protected static final String MISSING_ID_UPPER_CASE
protected final String schemaName
protected final DirContext dirContext
protected final String idAttribute
protected final String searchBaseDn
protected final Map<String,Field> schemaFieldMap
protected BaseDirectoryDescriptor.SubstringMatchType substringMatchType
protected final String rdnAttribute
protected final String passwordHashAlgorithm
public LDAPSession(LDAPDirectory directory, DirContext dirContext)
public LDAPDirectory getDirectory()
BaseSessiongetDirectory in class BaseSessionpublic DirContext getContext()
public DocumentModel createEntry(Map<String,Object> fieldMap)
SessioncreateEntry in interface SessionfieldMap - A map with keys and values that should be stored in a directory
Note: The values in the map should be of type String
public DocumentModel getEntry(String id) throws DirectoryException
SessionTODO what happens when the entry is not found? return null if not found?
getEntry in interface Sessionid - the entry idDirectoryExceptionpublic DocumentModel getEntry(String id, boolean fetchReferences) throws DirectoryException
SessiongetEntry in interface Sessionid - the entry idfetchReferences - boolean stating if references have to be fetchedDirectoryExceptionpublic DocumentModel getEntryFromSource(String id, boolean fetchReferences) throws DirectoryException
getEntryFromSource in interface EntrySourceDirectoryExceptionpublic boolean hasEntry(String id) throws DirectoryException
SessionhasEntry in interface SessionDirectoryExceptionprotected SearchResult getLdapEntry(String id) throws NamingException, DirectoryException
NamingExceptionDirectoryExceptionprotected SearchResult getLdapEntry(String id, boolean fetchAllAttributes) throws NamingException
NamingExceptionpublic DocumentModelList getEntries() throws DirectoryException
SessionDocumentModelList#totalsize on the returned list will return
-2 as a special marker for truncated results.getEntries in interface SessionDirectoryExceptionSizeLimitExceededException - if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public void updateEntry(DocumentModel docModel)
SessionupdateEntry in interface SessiondocModel - The entry to updateprotected void handleException(Exception e, String message)
public void deleteEntry(DocumentModel dm)
SessiondeleteEntry in interface Sessiondm - The entry to deletepublic void deleteEntry(String id)
SessiondeleteEntry in interface Sessionid - the id of the entry to deletepublic void deleteEntry(String id, Map<String,String> map)
SessionThis is used for hierarchical vocabularies, where the actual unique key is the couple (parent, id).
deleteEntry in interface Sessionid - the id of the entry to delete.map - a map of seconday key values.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, boolean fetchReferences, Map<String,String> orderBy) throws DirectoryException
DirectoryExceptionpublic DocumentModelList query(Map<String,Serializable> filter) throws DirectoryException
SessionDoes not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsize on the returned list will return -2 as a special marker for truncated
results.query in interface Sessionfilter - a filter to apply to entries in directoryDirectoryException - if a communication error occursSizeLimitExceededException - if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy) throws DirectoryException
SessionfieldNames present in the fulltext set are treated as a fulltext match. Does not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsize on the returned list will return -2 as a special marker for truncated
results.query in interface Sessionfilter - a filter to apply to entries in directoryfulltext - a set of field that should be treated as a fulltext searchorderBy - a LinkedHashMap with the 'order by' criterias.The key of an entry of this map represents the
column name and the value of the same entry represent the column order,which may be 'asc' or 'desc'.DirectoryException - if a communication error occursSizeLimitExceededException - if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext, Map<String,String> orderBy, boolean fetchReferences) throws DirectoryException
Sessionquery in interface SessionDirectoryExceptionSession.query(Map, Set, Map)public DocumentModelList query(Map<String,Serializable> filter, Set<String> fulltext) throws DirectoryException
SessionfieldNames present in the fulltext set are treated as a fulltext match. Does not fetch reference fields.
If the remote server issues a size limit exceeded error while sending partial results up to that limit, the methodDocumentModelList#totalsize on the returned list will return -2 as a special marker for truncated
results.query in interface Sessionfilter - a filter to apply to entries in directoryfulltext - a set of field that should be treated as a fulltext searchDirectoryException - if a communication error occursSizeLimitExceededException - if the number of results is larger than the limit configured for the directory
and the server does not send partial results.public void close() throws DirectoryException
SessionReleases this Connection object's resources immediately instead of waiting for them to be automatically released.
TODO: should this operation auto-commit pending changes?
close in interface AutoCloseableclose in interface SessionDirectoryException - if a communication error occurspublic List<String> getProjection(Map<String,Serializable> filter, String columnName) throws DirectoryException
SessiongetProjection in interface Sessionfilter - the filter for the querycolumnName - the column whose content should be returnedDirectoryExceptionSizeLimitExceededException - if the number of results is larger than the limit configured for the directorypublic List<String> getProjection(Map<String,Serializable> filter, Set<String> fulltext, String columnName) throws DirectoryException
getProjection in interface SessionDirectoryExceptionprotected DocumentModel fieldMapToDocumentModel(Map<String,Object> fieldMap) throws DirectoryException
DirectoryExceptionprotected Object getFieldValue(Attribute attribute, String fieldName, String entryId, boolean fetchReferences) throws DirectoryException
DirectoryExceptionprotected Attribute getAttributeValue(String fieldName, Object value) throws DirectoryException
DirectoryExceptionprotected DocumentModelList ldapResultsToDocumentModels(NamingEnumeration<SearchResult> results, boolean fetchReferences) throws DirectoryException, NamingException
DirectoryExceptionNamingExceptionprotected DocumentModel ldapResultToDocumentModel(SearchResult result, String entryId, boolean fetchReferences) throws DirectoryException, NamingException
DirectoryExceptionNamingExceptionprotected String changeEntryIdCase(String id, String idFieldCase)
public boolean authenticate(String username, String password) throws DirectoryException
Sessionauthenticate in interface SessionDirectoryExceptionpublic boolean isAuthenticating() throws DirectoryException
SessionisAuthenticating in interface SessionisAuthenticating in class BaseSessionDirectoryExceptionpublic boolean rdnMatchesIdField()
protected List<String> getMandatoryAttributes(Attribute objectClassesAttribute) throws DirectoryException
DirectoryExceptionprotected List<String> getMandatoryAttributes() throws DirectoryException
DirectoryExceptionpublic DocumentModel createEntry(DocumentModel entry)
SessioncreateEntry in interface Sessionentry - the document model representing the entry to createCopyright © 2016 Nuxeo SA. All rights reserved.