Package org.nuxeo.ecm.directory.ldap
Class LDAPReference
- java.lang.Object
-
- org.nuxeo.ecm.directory.AbstractReference
-
- org.nuxeo.ecm.directory.ldap.LDAPReference
-
public class LDAPReference extends AbstractReference implements Cloneable
Implementation of the directory Reference interface that leverage two common ways of storing relationships in LDAP directories:- the static attribute strategy where a multi-valued attribute store the exhaustive list of distinguished names of the refereed entries (eg. the uniqueMember attribute of the groupOfUniqueNames objectclass)
- the dynamic attribute strategy where a potentially multi-valued attribute stores a ldap urls intensively describing the refereed LDAP entries (eg. the memberURLs attribute of the groupOfURLs objectclass)
Please note that both static and dynamic references are resolved in read mode whereas only the static attribute strategy is used when creating new references or when deleting existing ones (write / update mode).
Some design considerations behind the implementation of such reference can be found at: http://jira.nuxeo.org/browse/NXP-1506
- Author:
- Olivier Grisel
-
-
Field Summary
Fields Modifier and Type Field Description protected String
dynamicAttributeId
boolean
forceDnConsistencyCheck
protected String
staticAttributeId
protected LDAPDirectoryDescriptor
targetDirectoryDescriptor
-
Fields inherited from class org.nuxeo.ecm.directory.AbstractReference
fieldName, sourceDirectory, sourceDirectoryName, targetDirectory, targetDirectoryName
-
-
Constructor Summary
Constructors Constructor Description LDAPReference()
LDAPReference(ReferenceDescriptor referenceDescriptor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLinks(String sourceId, List<String> targetIds)
Store new links using the LDAP staticAttributeId strategy.void
addLinks(String sourceId, List<String> targetIds, Session session)
Adds the links between the source id and the target idsvoid
addLinks(List<String> sourceIds, String targetId)
Store new links using the LDAP staticAttributeId strategy.void
addLinks(List<String> sourceIds, String targetId, Session session)
Adds the links between the source ids and the target idLDAPReference
clone()
String
getDynamicAttributeId()
List<LDAPDynamicReferenceDescriptor>
getDynamicAttributes()
protected String
getIdForDn(LDAPSession session, String dn)
List<String>
getLdapTargetIds(Attributes attributes)
Optimized method to spare a LDAP request when the caller is a LDAPSession object that has already fetched the LDAP Attribute instances.Directory
getSourceDirectory()
List<String>
getSourceIdsForTarget(String targetId)
Fetch both statically and dynamically defined references and merge the results.protected LDAPDirectory
getSourceLDAPDirectory()
String
getStaticAttributeId()
String
getStaticAttributeId(DirectoryFieldMapper sourceFM)
Directory
getTargetDirectory()
protected LDAPDirectoryDescriptor
getTargetDirectoryDescriptor()
List<String>
getTargetIdsForSource(String sourceId)
Fetches both statically and dynamically defined references and merges the results.protected LDAPDirectory
getTargetLDAPDirectory()
boolean
isDynamic()
boolean
isStatic()
protected static String
pseudoNormalizeDn(String dn)
Simple helper that replaces ", " by "," in the provided dn and returns the lower case version of the result for comparison purpose.void
removeLinksForSource(String sourceId)
Remove existing statically defined links for the given source id (dynamic references remain unaltered)void
removeLinksForSource(String sourceId, Session session)
Removes all the links for a given source idvoid
removeLinksForTarget(String targetId)
Remove existing statically defined links for the given target id (dynamic references remain unaltered)void
removeLinksForTarget(String targetId, Session session)
Removes all the links for a given target idvoid
setFieldName(String fieldName)
void
setSourceIdsForTarget(String targetId, List<String> sourceIds)
Edit the list of statically defined references for a given target (dynamic references remain unaltered)void
setSourceIdsForTarget(String targetId, List<String> sourceIds, Session session)
Sets all source ids to be associated to the given target idvoid
setTargetDirectoryName(String targetDirectoryName)
void
setTargetIdsForSource(String sourceId, List<String> targetIds)
Set the list of statically defined references for a given source (dynamic references remain unaltered)void
setTargetIdsForSource(String sourceId, List<String> targetIds, Session session)
Sets all target ids to be associated to the given source idString
toString()
-
Methods inherited from class org.nuxeo.ecm.directory.AbstractReference
getFieldName, setSourceDirectoryName
-
-
-
-
Field Detail
-
forceDnConsistencyCheck
public boolean forceDnConsistencyCheck
-
targetDirectoryDescriptor
protected LDAPDirectoryDescriptor targetDirectoryDescriptor
-
staticAttributeId
protected String staticAttributeId
-
dynamicAttributeId
protected String dynamicAttributeId
-
-
Constructor Detail
-
LDAPReference
public LDAPReference()
-
LDAPReference
public LDAPReference(ReferenceDescriptor referenceDescriptor)
-
-
Method Detail
-
setFieldName
public void setFieldName(String fieldName)
-
isStatic
public boolean isStatic()
- Returns:
- true if the reference should resolve statically refereed entries (identified by dn-valued attribute)
-
getStaticAttributeId
public String getStaticAttributeId()
-
getStaticAttributeId
public String getStaticAttributeId(DirectoryFieldMapper sourceFM)
-
getDynamicAttributes
public List<LDAPDynamicReferenceDescriptor> getDynamicAttributes()
-
getDynamicAttributeId
public String getDynamicAttributeId()
-
isDynamic
public boolean isDynamic()
- Returns:
- true if the reference should resolve dynamically refereed entries (identified by a LDAP url-valued attribute)
-
setTargetDirectoryName
public void setTargetDirectoryName(String targetDirectoryName)
- Specified by:
setTargetDirectoryName
in interfaceReference
- Overrides:
setTargetDirectoryName
in classAbstractReference
-
getSourceDirectory
public Directory getSourceDirectory()
- Specified by:
getSourceDirectory
in interfaceReference
- Overrides:
getSourceDirectory
in classAbstractReference
-
getTargetDirectory
public Directory getTargetDirectory()
- Specified by:
getTargetDirectory
in interfaceReference
- Overrides:
getTargetDirectory
in classAbstractReference
-
getTargetLDAPDirectory
protected LDAPDirectory getTargetLDAPDirectory()
-
getSourceLDAPDirectory
protected LDAPDirectory getSourceLDAPDirectory()
-
getTargetDirectoryDescriptor
protected LDAPDirectoryDescriptor getTargetDirectoryDescriptor()
-
addLinks
public void addLinks(String sourceId, List<String> targetIds)
Store new links using the LDAP staticAttributeId strategy.- Specified by:
addLinks
in interfaceReference
- See Also:
Reference.addLinks(String, List)
-
addLinks
public void addLinks(List<String> sourceIds, String targetId)
Store new links using the LDAP staticAttributeId strategy.- Specified by:
addLinks
in interfaceReference
- See Also:
Reference.addLinks(List, String)
-
getSourceIdsForTarget
public List<String> getSourceIdsForTarget(String targetId)
Fetch both statically and dynamically defined references and merge the results.- Specified by:
getSourceIdsForTarget
in interfaceReference
- See Also:
Reference.getSourceIdsForTarget(String)
-
getTargetIdsForSource
public List<String> getTargetIdsForSource(String sourceId)
Fetches both statically and dynamically defined references and merges the results.- Specified by:
getTargetIdsForSource
in interfaceReference
- See Also:
Reference.getSourceIdsForTarget(String)
-
pseudoNormalizeDn
protected static String pseudoNormalizeDn(String dn) throws InvalidNameException
Simple helper that replaces ", " by "," in the provided dn and returns the lower case version of the result for comparison purpose.- Parameters:
dn
- the raw unnormalized dn- Returns:
- lowercase version without whitespace after commas
- Throws:
InvalidNameException
-
getLdapTargetIds
public List<String> getLdapTargetIds(Attributes attributes)
Optimized method to spare a LDAP request when the caller is a LDAPSession object that has already fetched the LDAP Attribute instances.This method should return the same results as the sister method: org.nuxeo .ecm.directory.Reference#getTargetIdsForSource(java.lang.String)
- Returns:
- target reference ids
-
getIdForDn
protected String getIdForDn(LDAPSession session, String dn)
-
removeLinksForSource
public void removeLinksForSource(String sourceId)
Remove existing statically defined links for the given source id (dynamic references remain unaltered)- Specified by:
removeLinksForSource
in interfaceReference
- See Also:
Reference.removeLinksForSource(String)
-
removeLinksForTarget
public void removeLinksForTarget(String targetId)
Remove existing statically defined links for the given target id (dynamic references remain unaltered)- Specified by:
removeLinksForTarget
in interfaceReference
- See Also:
Reference.removeLinksForTarget(String)
-
setSourceIdsForTarget
public void setSourceIdsForTarget(String targetId, List<String> sourceIds)
Edit the list of statically defined references for a given target (dynamic references remain unaltered)- Specified by:
setSourceIdsForTarget
in interfaceReference
- See Also:
Reference.setSourceIdsForTarget(String, List)
-
setSourceIdsForTarget
public void setSourceIdsForTarget(String targetId, List<String> sourceIds, Session session)
Description copied from interface:Reference
Sets all source ids to be associated to the given target id- Specified by:
setSourceIdsForTarget
in interfaceReference
- Parameters:
targetId
- the target idsourceIds
- the source idssession
- the session
-
setTargetIdsForSource
public void setTargetIdsForSource(String sourceId, List<String> targetIds)
Set the list of statically defined references for a given source (dynamic references remain unaltered)- Specified by:
setTargetIdsForSource
in interfaceReference
- See Also:
Reference.setTargetIdsForSource(String, List)
-
setTargetIdsForSource
public void setTargetIdsForSource(String sourceId, List<String> targetIds, Session session)
Description copied from interface:Reference
Sets all target ids to be associated to the given source id- Specified by:
setTargetIdsForSource
in interfaceReference
- Parameters:
sourceId
- the source idtargetIds
- the target idssession
- the session
-
removeLinksForTarget
public void removeLinksForTarget(String targetId, Session session)
Description copied from interface:Reference
Removes all the links for a given target id- Specified by:
removeLinksForTarget
in interfaceReference
- Parameters:
targetId
- the target idsession
- the session
-
removeLinksForSource
public void removeLinksForSource(String sourceId, Session session)
Description copied from interface:Reference
Removes all the links for a given source id- Specified by:
removeLinksForSource
in interfaceReference
- Parameters:
sourceId
- the source idsession
- the session
-
clone
public LDAPReference clone()
-
addLinks
public void addLinks(String sourceId, List<String> targetIds, Session session)
Description copied from interface:Reference
Adds the links between the source id and the target ids
-
-