Search in sources :

Example 61 with LDAPMessage

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;
}
Also used : LogRecord(java.util.logging.LogRecord) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) SearchResultDoneProtocolOp(com.unboundid.ldap.protocol.SearchResultDoneProtocolOp) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) NotNull(com.unboundid.util.NotNull)

Example 62 with LDAPMessage

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;
}
Also used : LogRecord(java.util.logging.LogRecord) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) ModifyResponseProtocolOp(com.unboundid.ldap.protocol.ModifyResponseProtocolOp) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) NotNull(com.unboundid.util.NotNull)

Example 63 with LDAPMessage

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;
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) BindResponseProtocolOp(com.unboundid.ldap.protocol.BindResponseProtocolOp) LogRecord(java.util.logging.LogRecord) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) NotNull(com.unboundid.util.NotNull)

Example 64 with LDAPMessage

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;
}
Also used : LogRecord(java.util.logging.LogRecord) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) CompareResponseProtocolOp(com.unboundid.ldap.protocol.CompareResponseProtocolOp) NotNull(com.unboundid.util.NotNull)

Example 65 with LDAPMessage

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;
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ExtendedResponseProtocolOp(com.unboundid.ldap.protocol.ExtendedResponseProtocolOp) LogRecord(java.util.logging.LogRecord) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) NotNull(com.unboundid.util.NotNull)

Aggregations

LDAPMessage (com.unboundid.ldap.protocol.LDAPMessage)92 NotNull (com.unboundid.util.NotNull)72 LDAPException (com.unboundid.ldap.sdk.LDAPException)42 Control (com.unboundid.ldap.sdk.Control)25 LogRecord (java.util.logging.LogRecord)24 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)23 ArrayList (java.util.ArrayList)19 TransactionSpecificationRequestControl (com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl)14 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)13 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)13 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)13 AuthorizationIdentityResponseControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl)13 DontUseCopyRequestControl (com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl)13 DraftLDUPSubentriesRequestControl (com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl)13 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)13 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)13 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)13 PostReadResponseControl (com.unboundid.ldap.sdk.controls.PostReadResponseControl)13 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)13 PreReadResponseControl (com.unboundid.ldap.sdk.controls.PreReadResponseControl)13