use of com.unboundid.ldap.protocol.LDAPResponse in project ldapsdk by pingidentity.
the class ModifyRequest method process.
/**
* Sends this modify request to the directory server over the provided
* connection and returns the associated response.
*
* @param connection The connection to use to communicate with the directory
* server.
* @param depth The current referral depth for this request. It should
* always be one for the initial request, and should only
* be incremented when following referrals.
*
* @return An LDAP result object that provides information about the result
* of the modify processing.
*
* @throws LDAPException If a problem occurs while sending the request or
* reading the response.
*/
@Override()
@NotNull()
protected LDAPResult process(@NotNull final LDAPConnection connection, final int depth) throws LDAPException {
if (connection.synchronousMode()) {
@SuppressWarnings("deprecation") final boolean autoReconnect = connection.getConnectionOptions().autoReconnect();
return processSync(connection, depth, autoReconnect);
}
final long requestTime = System.nanoTime();
processAsync(connection, null);
try {
// Wait for and process the response.
final LDAPResponse response;
try {
final long responseTimeout = getResponseTimeoutMillis(connection);
if (responseTimeout > 0) {
response = responseQueue.poll(responseTimeout, TimeUnit.MILLISECONDS);
} else {
response = responseQueue.take();
}
} catch (final InterruptedException ie) {
Debug.debugException(ie);
Thread.currentThread().interrupt();
throw new LDAPException(ResultCode.LOCAL_ERROR, ERR_MODIFY_INTERRUPTED.get(connection.getHostPort()), ie);
}
return handleResponse(connection, response, requestTime, depth, false);
} finally {
connection.deregisterResponseAcceptor(messageID);
}
}
use of com.unboundid.ldap.protocol.LDAPResponse in project ldapsdk by pingidentity.
the class SASLBindRequest method sendMessage.
/**
* Sends an LDAP message to the directory server and waits for the response.
*
* @param connection The connection to the directory server.
* @param requestMessage The LDAP message to send to the directory server.
* @param timeoutMillis The maximum length of time in milliseconds to wait
* for a response, or zero if it should wait forever.
*
* @return The response message received from the server.
*
* @throws LDAPException If a problem occurs while sending the request or
* reading the response, or if a timeout occurred
* while waiting for the response.
*/
@NotNull()
protected final BindResult sendMessage(@NotNull final LDAPConnection connection, @NotNull final LDAPMessage requestMessage, final long timeoutMillis) throws LDAPException {
if (connection.synchronousMode()) {
return sendMessageSync(connection, requestMessage, timeoutMillis);
}
final int msgID = requestMessage.getMessageID();
connection.registerResponseAcceptor(msgID, this);
try {
Debug.debugLDAPRequest(Level.INFO, this, msgID, connection);
final LDAPConnectionLogger logger = connection.getConnectionOptions().getConnectionLogger();
if (logger != null) {
logger.logBindRequest(connection, messageID, this);
}
final long requestTime = System.nanoTime();
connection.getConnectionStatistics().incrementNumBindRequests();
connection.sendMessage(requestMessage, timeoutMillis);
// Wait for and process the response.
final LDAPResponse response;
try {
if (timeoutMillis > 0) {
response = responseQueue.poll(timeoutMillis, TimeUnit.MILLISECONDS);
} else {
response = responseQueue.take();
}
} catch (final InterruptedException ie) {
Debug.debugException(ie);
Thread.currentThread().interrupt();
throw new LDAPException(ResultCode.LOCAL_ERROR, ERR_BIND_INTERRUPTED.get(connection.getHostPort()), ie);
}
return handleResponse(connection, response, requestTime);
} finally {
connection.deregisterResponseAcceptor(msgID);
}
}
use of com.unboundid.ldap.protocol.LDAPResponse in project ldapsdk by pingidentity.
the class SASLBindRequest method sendMessageSync.
/**
* Sends an LDAP message to the directory server and waits for the response.
* This should only be used when the connection is operating in synchronous
* mode.
*
* @param connection The connection to the directory server.
* @param requestMessage The LDAP message to send to the directory server.
* @param timeoutMillis The maximum length of time in milliseconds to wait
* for a response, or zero if it should wait forever.
*
* @return The response message received from the server.
*
* @throws LDAPException If a problem occurs while sending the request or
* reading the response, or if a timeout occurred
* while waiting for the response.
*/
@NotNull()
private BindResult sendMessageSync(@NotNull final LDAPConnection connection, @NotNull final LDAPMessage requestMessage, final long timeoutMillis) throws LDAPException {
final int msgID = requestMessage.getMessageID();
Debug.debugLDAPRequest(Level.INFO, this, msgID, connection);
final LDAPConnectionLogger logger = connection.getConnectionOptions().getConnectionLogger();
if (logger != null) {
logger.logBindRequest(connection, messageID, this);
}
final long requestTime = System.nanoTime();
connection.getConnectionStatistics().incrementNumBindRequests();
connection.sendMessage(requestMessage, timeoutMillis);
while (true) {
final LDAPResponse response = connection.readResponse(messageID);
if (response instanceof IntermediateResponse) {
final IntermediateResponseListener listener = getIntermediateResponseListener();
if (listener != null) {
listener.intermediateResponseReturned((IntermediateResponse) response);
}
} else {
return handleResponse(connection, response, requestTime);
}
}
}
Aggregations