public class LDAPUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CT_ENCRYPTED
Signifies SSL/TLS encryption.
|
static java.lang.String |
CT_PLAIN
Signifies unencrypted comunication.
|
static java.lang.String |
CT_STARTTLS
Signifies encryption via StartTLS.
|
static java.lang.String |
TRUST_ALL
Implicitly trusts all server certificates (no check).
|
static java.lang.String |
TRUST_DEFAULT
Use system default trust store for server certificate check.
|
static java.lang.String |
TRUST_EP
Use @enterprise trust store for server certificate check.
|
Constructor and Description |
---|
LDAPUtils() |
Modifier and Type | Method and Description |
---|---|
static javax.naming.directory.DirContext |
connect(DirectoryServer ds)
Connect to a directory server.
|
static javax.naming.directory.DirContext |
connect(java.lang.String server,
java.lang.String port,
java.lang.String searchRoot,
java.lang.String username,
java.lang.String password,
java.lang.String communicationType,
java.lang.String trustLevel,
java.lang.String timeoutMs)
Connect to a directory server.
|
static Page |
connectAndList(javax.servlet.http.HttpServletRequest req)
Connect to an LDAP Server and list its contents
|
static javax.naming.directory.DirContext |
createSubcontext(javax.naming.directory.DirContext baseContext,
ClassMapping cm)
Create a subcontext of a basecontext, as specified by a class mapping.
|
static void |
deleteSubtree(javax.naming.directory.DirContext ctx)
Recursivly delete a subtree in the LDAP-Server
|
static java.lang.String |
extractRDNVal(java.lang.String dn)
Extract the Value of the RDN from a String which is a DN
|
static javax.naming.directory.Attribute |
getAttribute(DirectoryServer ds,
AttributeMapping am,
Persistent o)
Construct an Attribute from a Persistent and an Attribute Mapping
|
static java.lang.Object |
getAttValue(DirectoryServer ds,
AttributeMapping am,
Persistent o)
Get an attribute value from an Persistent and an AttributeMapping
|
static java.lang.String |
getDN(ClassMapping cm,
Persistent o)
Get the distinguished name of an Persistent relative to the root
|
static java.lang.String |
getSearchExpression(javax.naming.directory.Attributes attribs,
java.lang.Class<?> clazz,
ClassMapping cm,
javax.naming.directory.DirContext objectCtx,
Persistent parentObject,
java.lang.String parentField)
Create a SQL search expression for an LDAP object.
|
static java.lang.String |
getSearchOid(Persistent o)
Get a LDAP search expression for a Persistent based on Attribute entOid
|
static java.util.List<javax.naming.directory.SearchResult> |
getSearchResults(DirectoryServer ds,
javax.naming.directory.DirContext baseContext,
javax.naming.directory.SearchControls searchcons) |
static java.lang.String |
getSearchString(ClassMapping cm,
javax.naming.directory.DirContext ctx)
Construct a LDAP search string for a dircontext based on the RDN attribute
|
static java.lang.String |
getSearchString(DirectoryServer ds,
ClassMapping cm,
Persistent o)
Construct a LDAP search string for a Persistent based on the RDN attribute
|
static javax.naming.directory.DirContext |
getSubContext(javax.naming.directory.DirContext baseContext,
ClassMapping cm)
Get a subcontext of a basecontext, as specified ba a class mapping
|
static void |
setField(java.lang.reflect.Field ff,
java.lang.Object o,
java.lang.Object val)
Set a field of the given object to a value
|
static void |
setNull(java.lang.reflect.Field ff,
java.lang.Object o)
Set the given field of an Object to an appropriate value for null
|
static void |
setSQLAttributes(Persistent o,
javax.naming.directory.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(javax.servlet.http.HttpServletRequest req)
Synchronize with a directory Server
|
public static final java.lang.String CT_PLAIN
public static final java.lang.String CT_ENCRYPTED
public static final java.lang.String CT_STARTTLS
public static final java.lang.String TRUST_ALL
public static final java.lang.String TRUST_DEFAULT
public static final java.lang.String TRUST_EP
public static Page connectAndList(javax.servlet.http.HttpServletRequest req) throws java.lang.Exception
req
- java.lang.Exception
public static java.util.List<javax.naming.directory.SearchResult> getSearchResults(DirectoryServer ds, javax.naming.directory.DirContext baseContext, javax.naming.directory.SearchControls searchcons) throws javax.naming.NamingException, java.io.IOException
javax.naming.NamingException
java.io.IOException
public Page sync(javax.servlet.http.HttpServletRequest req) throws java.lang.Exception
req
- java.lang.Exception
public static void sync(DirectoryServer ds, boolean throwEx) throws java.lang.Exception
ds
- the server to synchronize withjava.lang.Exception
public static javax.naming.directory.DirContext connect(DirectoryServer ds) throws javax.naming.NamingException, java.io.IOException
ds
- the directory server to connect toNamingException,
- IOExceptionjavax.naming.NamingException
java.io.IOException
public static javax.naming.directory.DirContext connect(java.lang.String server, java.lang.String port, java.lang.String searchRoot, java.lang.String username, java.lang.String password, java.lang.String communicationType, java.lang.String trustLevel, java.lang.String timeoutMs) throws javax.naming.NamingException, java.io.IOException
ds
- the directory server to connect tojavax.naming.NamingException
java.io.IOException
public static javax.naming.directory.DirContext getSubContext(javax.naming.directory.DirContext baseContext, ClassMapping cm) throws java.lang.Exception
baseContext
- the case contextcm
- the class mapping which specifies the subcontextjava.lang.Exception
public static javax.naming.directory.DirContext createSubcontext(javax.naming.directory.DirContext baseContext, ClassMapping cm) throws java.lang.Exception
baseContext
- the case contextcm
- the class mapping which specifies the subcontextjava.lang.Exception
public static void deleteSubtree(javax.naming.directory.DirContext ctx) throws java.lang.Exception
ctx
- the root of the tree to be deletedjava.lang.Exception
public static java.lang.String getSearchString(ClassMapping cm, javax.naming.directory.DirContext ctx) throws java.lang.Exception
cm
- the appropriate class mapping for the dir contextctx
- the context to construct the search string forjava.lang.Exception
public static java.lang.String getSearchString(DirectoryServer ds, ClassMapping cm, Persistent o) throws java.lang.Exception
ds
- thecm
- o
- java.lang.Exception
public static java.lang.String getSearchOid(Persistent o) throws java.lang.Exception
o
- the Persistent for which the search expression is to be generatedjava.lang.Exception
public static java.lang.String getDN(ClassMapping cm, Persistent o) throws java.lang.Exception
cm
- an appropriate class mapping for the persistento
- the object to generate the DN forjava.lang.Exception
public static javax.naming.directory.Attribute getAttribute(DirectoryServer ds, AttributeMapping am, Persistent o) throws java.lang.Exception
ds
- the directory serveram
- the attribute mappingo
- the Persistentjava.lang.Exception
public static java.lang.Object getAttValue(DirectoryServer ds, AttributeMapping am, Persistent o) throws java.lang.Exception
ds
- the directory serveram
- the attribute mappingo
- the Persistentjava.lang.Exception
public static void setSQLAttributes(Persistent o, javax.naming.directory.DirContext objectCtx, ClassMapping cm) throws java.lang.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 objectCtxjava.lang.Exception
public static java.lang.String getSearchExpression(javax.naming.directory.Attributes attribs, java.lang.Class<?> clazz, ClassMapping cm, javax.naming.directory.DirContext objectCtx, Persistent parentObject, java.lang.String parentField) throws java.lang.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)java.lang.Exception
public static void setNull(java.lang.reflect.Field ff, java.lang.Object o) throws java.lang.Exception
ff
- the Field to seto
- the Object whose field is to be setjava.lang.Exception
public static void setField(java.lang.reflect.Field ff, java.lang.Object o, java.lang.Object val) throws java.lang.Exception
ff
- the field to seto
- the Object whose field is to be setval
- the value to set the field tojava.lang.Exception
public static java.lang.String extractRDNVal(java.lang.String dn)
dn
- the distinguidhed name@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.