public class LDAPUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CT_ENCRYPTED
Signifies SSL/TLS encryption.
|
static String |
CT_PLAIN
Signifies unencrypted comunication.
|
static String |
CT_STARTTLS
Signifies encryption via StartTLS.
|
static String |
TRUST_ALL
Implicitly trusts all server certificates (no check).
|
static String |
TRUST_DEFAULT
Use system default trust store for server certificate check.
|
static String |
TRUST_EP
Use @enterprise trust store for server certificate check.
|
Constructor and Description |
---|
LDAPUtils() |
Modifier and Type | Method and Description |
---|---|
static DirContext |
connect(DirectoryServer ds)
Connect to a directory server.
|
static DirContext |
connect(String server,
String port,
String searchRoot,
String username,
String password,
String communicationType,
String trustLevel,
String timeoutMs)
Connect to a directory server.
|
static Page |
connectAndList(HttpServletRequest r)
Connect to an LDAP Server and list its contents
|
static DirContext |
createSubcontext(DirContext baseContext,
ClassMapping cm)
Create a subcontext of a basecontext, as specified by a class mapping.
|
static void |
deleteSubtree(DirContext ctx)
Recursivly delete a subtree in the LDAP-Server
|
static String |
extractRDNVal(String dn)
Extract the Value of the RDN from a String which is a DN
|
static Attribute |
getAttribute(DirectoryServer ds,
AttributeMapping am,
Persistent o)
Construct an Attribute from a Persistent and an Attribute Mapping
|
static Object |
getAttValue(DirectoryServer ds,
AttributeMapping am,
Persistent o)
Get an attribute value from an Persistent and an AttributeMapping
|
static String |
getDN(ClassMapping cm,
Persistent o)
Get the distinguished name of an Persistent relative to the root
|
static String |
getSearchExpression(Attributes attribs,
Class<?> clazz,
ClassMapping cm,
DirContext objectCtx,
Persistent parentObject,
String parentField)
Create a SQL search expression for an LDAP object.
|
static String |
getSearchOid(Persistent o)
Get a LDAP search expression for a Persistent based on Attribute entOid
|
static List<SearchResult> |
getSearchResults(DirectoryServer ds,
DirContext baseContext,
SearchControls searchcons) |
static String |
getSearchString(ClassMapping cm,
DirContext ctx)
Construct a LDAP search string for a dircontext based on the RDN attribute
|
static String |
getSearchString(DirectoryServer ds,
ClassMapping cm,
Persistent o)
Construct a LDAP search string for a Persistent based on the RDN attribute
|
static DirContext |
getSubContext(DirContext baseContext,
ClassMapping cm)
Get a subcontext of a basecontext, as specified ba a class mapping
|
static void |
setField(Field ff,
Object o,
Object val)
Set a field of the given object to a value
|
static void |
setNull(Field ff,
Object o)
Set the given field of an Object to an appropriate value for null
|
static void |
setSQLAttributes(Persistent o,
DirContext objectCtx,
ClassMapping cm)
Set the fields of the Persistent that corresponds to the given DirContext based on the ClassMapping
|
static void |
sync(DirectoryServer ds,
boolean throwEx)
Synchronize with a directory server.
|
Page |
sync(HttpServletRequest r)
Synchronize with a directory Server
|
public static final String CT_PLAIN
public static final String CT_ENCRYPTED
public static final String CT_STARTTLS
public static final String TRUST_ALL
public static final String TRUST_DEFAULT
public static final String TRUST_EP
public static Page connectAndList(HttpServletRequest r) throws Exception
r
- Exception
public static List<SearchResult> getSearchResults(DirectoryServer ds, DirContext baseContext, SearchControls searchcons) throws NamingException, IOException
NamingException
IOException
public Page sync(HttpServletRequest r) throws Exception
r
- Exception
public static void sync(DirectoryServer ds, boolean throwEx) throws Exception
ds
- the server to synchronize withException
public static DirContext connect(DirectoryServer ds) throws NamingException, IOException
ds
- the directory server to connect toNamingException
IOException
public static DirContext connect(String server, String port, String searchRoot, String username, String password, String communicationType, String trustLevel, String timeoutMs) throws NamingException, IOException
NamingException
IOException
public static DirContext getSubContext(DirContext baseContext, ClassMapping cm) throws Exception
baseContext
- the case contextcm
- the class mapping which specifies the subcontextException
public static DirContext createSubcontext(DirContext baseContext, ClassMapping cm) throws Exception
baseContext
- the case contextcm
- the class mapping which specifies the subcontextException
public static void deleteSubtree(DirContext ctx) throws Exception
ctx
- the root of the tree to be deletedException
public static String getSearchString(ClassMapping cm, DirContext ctx) throws Exception
cm
- the appropriate class mapping for the dir contextctx
- the context to construct the search string forException
public static String getSearchString(DirectoryServer ds, ClassMapping cm, Persistent o) throws Exception
ds
- thecm
- o
- Exception
public static String getSearchOid(Persistent o)
o
- the Persistent for which the search expression is to be generatedpublic static String getDN(ClassMapping cm, Persistent o) throws Exception
cm
- an appropriate class mapping for the persistento
- the object to generate the DN forException
public static Attribute getAttribute(DirectoryServer ds, AttributeMapping am, Persistent o) throws Exception
ds
- the directory serveram
- the attribute mappingo
- the PersistentException
public static Object getAttValue(DirectoryServer ds, AttributeMapping am, Persistent o) throws Exception
ds
- the directory serveram
- the attribute mappingo
- the PersistentException
public static void setSQLAttributes(Persistent o, DirContext objectCtx, ClassMapping cm) throws Exception
o
- the Persistent whose fields are to be filledobjectCtx
- the directory context whose attribute values are to be filled into the Persistentcm
- an appropriate ClassMapping between o and objectCtxException
public static String getSearchExpression(Attributes attribs, Class<?> clazz, ClassMapping cm, DirContext objectCtx, Persistent parentObject, String parentField) throws Exception
attribs
- the Attributes of the LDAP objectclazz
- the class of the Persistentcm
- an appropriate class mappingobjectCtx
- the LDAP objectparentObject
- the SQL parent object of the LDAP objectparentField
- the SQL field by which the parent object is linked to the Persistent (foreign key)Exception
public static void setNull(Field ff, Object o) throws Exception
ff
- the Field to seto
- the Object whose field is to be setException
public static void setField(Field ff, Object o, Object val) throws Exception
ff
- the field to seto
- the Object whose field is to be setval
- the value to set the field toException
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.