use of com.unboundid.ldap.protocol.BindRequestProtocolOp in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorRequestHandler method processBindRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processBindRequest(final int messageID, @NotNull final BindRequestProtocolOp request, @NotNull final List<Control> controls) {
if (request.getCredentialsType() == BindRequestProtocolOp.CRED_TYPE_SIMPLE) {
final InterceptedSimpleBindOperation op = new InterceptedSimpleBindOperation(connection, messageID, request, toArray(controls));
activeOperations.put(messageID, op);
try {
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSimpleBindRequest(op);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new BindResponseProtocolOp(le.toLDAPResult()), le.getResponseControls());
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new BindResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_REQUEST_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null, null));
}
}
final LDAPMessage resultMessage = wrappedHandler.processBindRequest(messageID, new BindRequestProtocolOp(op.getRequest()), op.getRequest().getControlList());
op.setResult(resultMessage.getBindResponseProtocolOp().toBindResult(toArray(resultMessage.getControls())));
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSimpleBindResult(op);
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new BindResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_RESULT_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null, null));
}
}
return new LDAPMessage(messageID, new BindResponseProtocolOp(op.getResult()), op.getResult().getResponseControls());
} finally {
activeOperations.remove(messageID);
}
} else {
final InterceptedSASLBindOperation op = new InterceptedSASLBindOperation(connection, messageID, request, toArray(controls));
activeOperations.put(messageID, op);
try {
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSASLBindRequest(op);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new BindResponseProtocolOp(le.toLDAPResult()), le.getResponseControls());
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new BindResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_REQUEST_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null, null));
}
}
final LDAPMessage resultMessage = wrappedHandler.processBindRequest(messageID, new BindRequestProtocolOp(op.getRequest()), op.getRequest().getControlList());
op.setResult(resultMessage.getBindResponseProtocolOp().toBindResult(toArray(resultMessage.getControls())));
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSASLBindResult(op);
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new BindResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_RESULT_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null, null));
}
}
return new LDAPMessage(messageID, new BindResponseProtocolOp(op.getResult()), op.getResult().getResponseControls());
} finally {
activeOperations.remove(messageID);
}
}
}
use of com.unboundid.ldap.protocol.BindRequestProtocolOp in project ldapsdk by pingidentity.
the class SASLBindRequest method sendBindRequest.
/**
* Sends an LDAP message to the directory server and waits for the response.
*
* @param connection The connection to the directory server.
* @param bindDN The bind DN to use for the request. It should be
* {@code null} for most types of SASL bind requests.
* @param saslCredentials The SASL credentials to use for the bind request.
* It may be {@code null} if no credentials are
* required.
* @param controls The set of controls to include in the request. It
* may be {@code null} if no controls are required.
* @param timeoutMillis The maximum length of time in milliseconds to wait
* for a response, or zero if it should wait forever.
*
* @return The bind response message returned by the directory 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 sendBindRequest(@NotNull final LDAPConnection connection, @Nullable final String bindDN, @Nullable final ASN1OctetString saslCredentials, @Nullable final Control[] controls, final long timeoutMillis) throws LDAPException {
messageID = connection.nextMessageID();
final BindRequestProtocolOp protocolOp = new BindRequestProtocolOp(bindDN, getSASLMechanismName(), saslCredentials);
final LDAPMessage requestMessage = new LDAPMessage(messageID, protocolOp, controls);
return sendMessage(connection, requestMessage, timeoutMillis);
}
Aggregations