use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class LDAPDebuggerRequestHandler method processSearchRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processSearchRequest(final int messageID, @NotNull final SearchRequestProtocolOp request, @NotNull final List<Control> controls) {
final StringBuilder b = getBuffer();
appendHeader(b, messageID);
b.append(" Search Request Protocol Op:").append(StaticUtils.EOL);
b.append(" Base DN: ").append(request.getBaseDN()).append(StaticUtils.EOL);
b.append(" Scope: ").append(request.getScope()).append(StaticUtils.EOL);
b.append(" Dereference Policy: ").append(request.getDerefPolicy()).append(StaticUtils.EOL);
b.append(" Size Limit: ").append(request.getSizeLimit()).append(StaticUtils.EOL);
b.append(" Time Limit: ").append(request.getSizeLimit()).append(StaticUtils.EOL);
b.append(" Types Only: ").append(request.typesOnly()).append(StaticUtils.EOL);
b.append(" Filter: ");
request.getFilter().toString(b);
b.append(StaticUtils.EOL);
final List<String> attributes = request.getAttributes();
if (!attributes.isEmpty()) {
b.append(" Requested Attributes:").append(StaticUtils.EOL);
for (final String attr : attributes) {
b.append(" ").append(attr).append(StaticUtils.EOL);
}
}
appendControls(b, controls);
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
final LDAPMessage responseMessage = requestHandler.processSearchRequest(messageID, request, controls);
b.setLength(0);
appendHeader(b, responseMessage.getMessageID());
b.append(" Search Result Done Protocol Op:").append(StaticUtils.EOL);
final SearchResultDoneProtocolOp protocolOp = responseMessage.getSearchResultDoneProtocolOp();
appendResponse(b, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs());
appendControls(b, responseMessage.getControls());
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
return responseMessage;
}
use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class LDAPDebuggerRequestHandler method processModifyRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processModifyRequest(final int messageID, @NotNull final ModifyRequestProtocolOp request, @NotNull final List<Control> controls) {
final StringBuilder b = getBuffer();
appendHeader(b, messageID);
b.append(" Modify Request Protocol Op:").append(StaticUtils.EOL);
final LDIFModifyChangeRecord changeRecord = new LDIFModifyChangeRecord(request.getDN(), request.getModifications());
final String[] ldifLines = changeRecord.toLDIF(80);
for (final String line : ldifLines) {
b.append(" ").append(line).append(StaticUtils.EOL);
}
appendControls(b, controls);
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
final LDAPMessage responseMessage = requestHandler.processModifyRequest(messageID, request, controls);
b.setLength(0);
appendHeader(b, responseMessage.getMessageID());
b.append(" Modify Response Protocol Op:").append(StaticUtils.EOL);
final ModifyResponseProtocolOp protocolOp = responseMessage.getModifyResponseProtocolOp();
appendResponse(b, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs());
appendControls(b, responseMessage.getControls());
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
return responseMessage;
}
use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class LDAPDebuggerRequestHandler method processBindRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processBindRequest(final int messageID, @NotNull final BindRequestProtocolOp request, @NotNull final List<Control> controls) {
final StringBuilder b = getBuffer();
appendHeader(b, messageID);
b.append(" Bind Request Protocol Op:").append(StaticUtils.EOL);
b.append(" LDAP Version: ").append(request.getVersion()).append(StaticUtils.EOL);
b.append(" Bind DN: ").append(request.getBindDN()).append(StaticUtils.EOL);
switch(request.getCredentialsType()) {
case BindRequestProtocolOp.CRED_TYPE_SIMPLE:
b.append(" Credentials Type: SIMPLE").append(StaticUtils.EOL);
b.append(" Password: ").append(request.getSimplePassword()).append(StaticUtils.EOL);
break;
case BindRequestProtocolOp.CRED_TYPE_SASL:
b.append(" Credentials Type: SASL").append(StaticUtils.EOL);
b.append(" Mechanism: ").append(request.getSASLMechanism()).append(StaticUtils.EOL);
final ASN1OctetString saslCredentials = request.getSASLCredentials();
if (saslCredentials != null) {
b.append(" Encoded Credentials:");
b.append(StaticUtils.EOL);
StaticUtils.toHexPlusASCII(saslCredentials.getValue(), 20, b);
}
break;
}
appendControls(b, controls);
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
final LDAPMessage responseMessage = requestHandler.processBindRequest(messageID, request, controls);
b.setLength(0);
appendHeader(b, responseMessage.getMessageID());
b.append(" Bind Response Protocol Op:").append(StaticUtils.EOL);
final BindResponseProtocolOp protocolOp = responseMessage.getBindResponseProtocolOp();
appendResponse(b, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs());
final ASN1OctetString serverSASLCredentials = protocolOp.getServerSASLCredentials();
if (serverSASLCredentials != null) {
b.append(" Encoded Server SASL Credentials:");
b.append(StaticUtils.EOL);
StaticUtils.toHexPlusASCII(serverSASLCredentials.getValue(), 20, b);
}
appendControls(b, responseMessage.getControls());
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
return responseMessage;
}
use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class LDAPDebuggerRequestHandler method processCompareRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processCompareRequest(final int messageID, @NotNull final CompareRequestProtocolOp request, @NotNull final List<Control> controls) {
final StringBuilder b = getBuffer();
appendHeader(b, messageID);
b.append(" Compare Request Protocol Op:").append(StaticUtils.EOL);
b.append(" DN: ").append(request.getDN()).append(StaticUtils.EOL);
b.append(" Attribute Type: ").append(request.getAttributeName()).append(StaticUtils.EOL);
b.append(" Assertion Value: ").append(request.getAssertionValue().stringValue()).append(StaticUtils.EOL);
appendControls(b, controls);
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
final LDAPMessage responseMessage = requestHandler.processCompareRequest(messageID, request, controls);
b.setLength(0);
appendHeader(b, responseMessage.getMessageID());
b.append(" Compare Response Protocol Op:").append(StaticUtils.EOL);
final CompareResponseProtocolOp protocolOp = responseMessage.getCompareResponseProtocolOp();
appendResponse(b, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs());
appendControls(b, responseMessage.getControls());
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
return responseMessage;
}
use of com.unboundid.ldap.protocol.LDAPMessage in project ldapsdk by pingidentity.
the class LDAPDebuggerRequestHandler method processExtendedRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processExtendedRequest(final int messageID, @NotNull final ExtendedRequestProtocolOp request, @NotNull final List<Control> controls) {
final StringBuilder b = getBuffer();
appendHeader(b, messageID);
b.append(" Extended Request Protocol Op:").append(StaticUtils.EOL);
b.append(" Request OID: ").append(request.getOID()).append(StaticUtils.EOL);
final ASN1OctetString requestValue = request.getValue();
if (requestValue != null) {
b.append(" Encoded Request Value:");
b.append(StaticUtils.EOL);
StaticUtils.toHexPlusASCII(requestValue.getValue(), 15, b);
}
appendControls(b, controls);
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
final LDAPMessage responseMessage = requestHandler.processExtendedRequest(messageID, request, controls);
b.setLength(0);
appendHeader(b, responseMessage.getMessageID());
b.append(" Extended Response Protocol Op:").append(StaticUtils.EOL);
final ExtendedResponseProtocolOp protocolOp = responseMessage.getExtendedResponseProtocolOp();
appendResponse(b, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs());
final String responseOID = protocolOp.getResponseOID();
if (responseOID != null) {
b.append(" Response OID: ").append(responseOID).append(StaticUtils.EOL);
}
final ASN1OctetString responseValue = protocolOp.getResponseValue();
if (responseValue != null) {
b.append(" Encoded Response Value:");
b.append(StaticUtils.EOL);
StaticUtils.toHexPlusASCII(responseValue.getValue(), 15, b);
}
appendControls(b, responseMessage.getControls());
logHandler.publish(new LogRecord(Level.INFO, b.toString()));
logHandler.flush();
return responseMessage;
}
Aggregations