public class JndiConnection extends java.lang.Object implements ProviderConnection
| Modifier and Type | Class and Description |
|---|---|
protected static class |
JndiConnection.JndiExtendedRequest
Class for exposing extended request properties.
|
protected static class |
JndiConnection.JndiExtendedResponse
Class for exposing extended response properties.
|
protected class |
JndiConnection.JndiSearchIterator
Search iterator for JNDI naming enumeration.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AUTHENTICATION
The value of this property is a string that specifies the authentication mechanism(s) for the provider to use.
|
static java.lang.String |
BINARY_ATTRIBUTES
The value of this property is a string that specifies additional binary attributes.
|
private JndiProviderConfig |
config
Provider configuration.
|
private javax.naming.ldap.LdapContext |
context
Ldap context.
|
static java.lang.String |
CREDENTIALS
The value of this property is an object that specifies the credentials of the principal to be authenticated.
|
static java.lang.String |
DELETE_RDN
The value of this property is a string that specifies whether the RDN attribute should be deleted for a modify dn
operation.
|
static java.lang.String |
DEREF_ALIASES
The value of this property is a string that specifies how aliases shall be handled by the provider.
|
protected org.slf4j.Logger |
logger
Logger for this class.
|
static java.lang.String |
PRINCIPAL
The value of this property is a string that specifies the identity of the principal to be authenticated.
|
static java.lang.String |
REFERRAL
The value of this property is a string that specifies how referrals shall be handled by the provider.
|
static java.lang.String |
SASL_AUTHZ_ID
The value of this property is a string that specifies the sasl authorization id.
|
static java.lang.String |
SASL_MUTUAL_AUTH
The value of this property is a string that specifies the sasl mutual authentication flag.
|
static java.lang.String |
SASL_QOP
The value of this property is a string that specifies the sasl quality of protection.
|
static java.lang.String |
SASL_REALM
The value of this property is a string that specifies the sasl realm.
|
static java.lang.String |
SASL_STRENGTH
The value of this property is a string that specifies the sasl security strength.
|
static java.lang.String |
TYPES_ONLY
The value of this property is a string that specifies to only return attribute type names, no values.
|
| Constructor and Description |
|---|
JndiConnection(javax.naming.ldap.LdapContext lc,
JndiProviderConfig pc)
Creates a new jndi connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abandon(int messageId,
RequestControl[] controls)
Abandon an operation.
|
Response<java.lang.Void> |
add(AddRequest request)
Add an entry to an ldap.
|
void |
addUnsolicitedNotificationListener(UnsolicitedNotificationListener listener)
Adds a listener to receive unsolicited notifications.
|
protected Response<java.lang.Void> |
anonymousBind(BindRequest request)
Performs an anonymous bind.
|
Response<java.lang.Void> |
bind(BindRequest request)
Bind to the ldap.
|
void |
close(RequestControl[] controls)
Tear down this connection to an LDAP.
|
Response<java.lang.Boolean> |
compare(CompareRequest request)
Compare an entry in the ldap.
|
protected <T> Response<T> |
createResponse(Request request,
T result,
ResultCode code,
java.lang.String[] urls,
javax.naming.ldap.LdapContext ctx)
Creates an operation response with the supplied response data.
|
Response<java.lang.Void> |
delete(DeleteRequest request)
Delete an entry in the ldap.
|
Response<?> |
extendedOperation(ExtendedRequest request)
Perform an extended operation in the ldap.
|
static javax.naming.directory.SearchControls |
getCompareSearchControls()
Returns a search controls object configured to perform an LDAP compare operation.
|
javax.naming.ldap.LdapContext |
getLdapContext()
Returns the underlying ldap context.
|
protected static java.util.Map<java.lang.String,java.lang.Object> |
getSaslProperties(SaslConfig config)
Returns the JNDI properties for the supplied sasl configuration.
|
protected javax.naming.ldap.LdapContext |
initializeContext(Request request)
Creates a new ldap context using
LdapContext.newInstance(Control[]). |
Response<java.lang.Void> |
modify(ModifyRequest request)
Modify an entry in the ldap.
|
Response<java.lang.Void> |
modifyDn(ModifyDnRequest request)
Modify the DN of an entry in the ldap.
|
protected void |
processNamingException(Request request,
javax.naming.NamingException e,
java.lang.String[] urls,
javax.naming.ldap.LdapContext ctx)
Determines if the supplied naming exception should result in an operation retry.
|
protected ResponseControl[] |
processResponseControls(ControlProcessor<javax.naming.ldap.Control> processor,
RequestControl[] requestControls,
javax.naming.ldap.LdapContext ctx)
Retrieves the response controls from the supplied context and processes them with the supplied control processor.
|
void |
removeUnsolicitedNotificationListener(UnsolicitedNotificationListener listener)
Removes a listener from receiving unsolicited notifications.
|
protected Response<java.lang.Void> |
saslBind(BindRequest request)
Performs a sasl bind.
|
SearchIterator |
search(SearchRequest request)
Search the ldap.
|
void |
searchAsync(SearchRequest request,
SearchListener listener)
Search the ldap asynchronously.
|
protected Response<java.lang.Void> |
simpleBind(BindRequest request)
Performs a simple bind.
|
public static final java.lang.String AUTHENTICATION
public static final java.lang.String CREDENTIALS
public static final java.lang.String PRINCIPAL
public static final java.lang.String SASL_AUTHZ_ID
public static final java.lang.String SASL_QOP
public static final java.lang.String SASL_STRENGTH
public static final java.lang.String SASL_MUTUAL_AUTH
public static final java.lang.String SASL_REALM
public static final java.lang.String DELETE_RDN
public static final java.lang.String BINARY_ATTRIBUTES
public static final java.lang.String DEREF_ALIASES
public static final java.lang.String REFERRAL
public static final java.lang.String TYPES_ONLY
protected final org.slf4j.Logger logger
private javax.naming.ldap.LdapContext context
private final JndiProviderConfig config
public JndiConnection(javax.naming.ldap.LdapContext lc,
JndiProviderConfig pc)
lc - ldap contextpc - provider configurationpublic javax.naming.ldap.LdapContext getLdapContext()
public void close(RequestControl[] controls) throws LdapException
ProviderConnectionclose in interface ProviderConnectioncontrols - request controlsLdapException - if an LDAP error occurspublic Response<java.lang.Void> bind(BindRequest request) throws LdapException
ProviderConnectionbind in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occursprotected Response<java.lang.Void> anonymousBind(BindRequest request) throws LdapException
request - to bind withLdapException - if an error occursprotected Response<java.lang.Void> simpleBind(BindRequest request) throws LdapException
request - to bind withLdapException - if an error occursprotected Response<java.lang.Void> saslBind(BindRequest request) throws LdapException
request - to bind withLdapException - if an error occurspublic Response<java.lang.Void> add(AddRequest request) throws LdapException
ProviderConnectionadd in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic Response<java.lang.Boolean> compare(CompareRequest request) throws LdapException
ProviderConnectioncompare in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic Response<java.lang.Void> delete(DeleteRequest request) throws LdapException
ProviderConnectiondelete in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic Response<java.lang.Void> modify(ModifyRequest request) throws LdapException
ProviderConnectionmodify in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic Response<java.lang.Void> modifyDn(ModifyDnRequest request) throws LdapException
ProviderConnectionmodifyDn in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic SearchIterator search(SearchRequest request) throws LdapException
ProviderConnectionsearch in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic void searchAsync(SearchRequest request, SearchListener listener) throws LdapException
ProviderConnectionsearchAsync in interface ProviderConnectionrequest - containing the data necessary to perform the operationlistener - to be notified as results arriveLdapException - if an error occurspublic void abandon(int messageId,
RequestControl[] controls)
throws LdapException
ProviderConnectionabandon in interface ProviderConnectionmessageId - of the operation to abandoncontrols - request controlsLdapException - if an error occurspublic Response<?> extendedOperation(ExtendedRequest request) throws LdapException
ProviderConnectionextendedOperation in interface ProviderConnectionrequest - containing the data necessary to perform the operationLdapException - if an error occurspublic void addUnsolicitedNotificationListener(UnsolicitedNotificationListener listener)
ProviderConnectionaddUnsolicitedNotificationListener in interface ProviderConnectionlistener - to receive unsolicited notificationspublic void removeUnsolicitedNotificationListener(UnsolicitedNotificationListener listener)
ProviderConnectionremoveUnsolicitedNotificationListener in interface ProviderConnectionlistener - that was registered to receive unsolicited notificationspublic static javax.naming.directory.SearchControls getCompareSearchControls()
protected javax.naming.ldap.LdapContext initializeContext(Request request) throws javax.naming.NamingException
LdapContext.newInstance(Control[]). Adds any additional environment
properties found in the supplied request to the context.request - to read properties fromjavax.naming.NamingException - if a property cannot be added to the contextprotected <T> Response<T> createResponse(Request request, T result, ResultCode code, java.lang.String[] urls, javax.naming.ldap.LdapContext ctx)
T - type of responserequest - containing controlsresult - of the operationcode - operation result codeurls - referral urlsctx - ldap contextprotected void processNamingException(Request request, javax.naming.NamingException e, java.lang.String[] urls, javax.naming.ldap.LdapContext ctx) throws LdapException
request - that produced the exceptione - that was producedurls - referral urlsctx - that the exception occurred onLdapException - wrapping the naming exceptionprotected ResponseControl[] processResponseControls(ControlProcessor<javax.naming.ldap.Control> processor, RequestControl[] requestControls, javax.naming.ldap.LdapContext ctx)
processor - control processorrequestControls - that produced this responsectx - to get controls fromprotected static java.util.Map<java.lang.String,java.lang.Object> getSaslProperties(SaslConfig config)
config - sasl configuration