Search in sources :

Example 36 with IntermediateResponse

use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.

the class ControlBasedOperationInterceptor method processAddResult.

/**
 * {@inheritDoc}
 */
@Override()
public void processAddResult(final InMemoryInterceptedAddResult result) {
    // See if there are any transformations that should be applied.
    final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
    if (transformTypesObj == null) {
        return;
    }
    @SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
    if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
        try {
            result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
        try {
            result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.ERROR_RESULT)) {
        result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
    }
    if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
        throw new RuntimeException();
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) EnumSet(java.util.EnumSet) Set(java.util.Set) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Example 37 with IntermediateResponse

use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.

the class ControlBasedOperationInterceptor method processDeleteResult.

/**
 * {@inheritDoc}
 */
@Override()
public void processDeleteResult(final InMemoryInterceptedDeleteResult result) {
    // See if there are any transformations that should be applied.
    final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
    if (transformTypesObj == null) {
        return;
    }
    @SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
    if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
        try {
            result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
        try {
            result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.ERROR_RESULT)) {
        result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
    }
    if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
        throw new RuntimeException();
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) EnumSet(java.util.EnumSet) Set(java.util.Set) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Example 38 with IntermediateResponse

use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.

the class ControlBasedOperationInterceptor method processSearchResult.

/**
 * {@inheritDoc}
 */
@Override()
public void processSearchResult(final InMemoryInterceptedSearchResult result) {
    // See if there are any transformations that should be applied.
    final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
    if (transformTypesObj == null) {
        return;
    }
    @SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
    if (transformTypes.contains(TransformType.INJECT_ENTRY)) {
        try {
            result.sendSearchEntry(new Entry("dn: ou=Result,ou=injected,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: Result"));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_REFERENCE)) {
        try {
            final String[] referralURLs = { "ldap://" + result.getConnectedAddress() + ':' + result.getConnectedPort() + "/ou=Result,ou=injected,dc=example,dc=com" };
            result.sendSearchReference(new SearchResultReference(referralURLs, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
        try {
            result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
        try {
            result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.ERROR_RESULT)) {
        result.setResult(new LDAPResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS));
    }
    if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
        throw new RuntimeException();
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) EnumSet(java.util.EnumSet) Set(java.util.Set) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) SearchResultReference(com.unboundid.ldap.sdk.SearchResultReference) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPException(com.unboundid.ldap.sdk.LDAPException) Entry(com.unboundid.ldap.sdk.Entry) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult)

Example 39 with IntermediateResponse

use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.

the class ControlBasedOperationInterceptor method processSimpleBindResult.

/**
 * {@inheritDoc}
 */
@Override()
public void processSimpleBindResult(final InMemoryInterceptedSimpleBindResult result) {
    // See if there are any transformations that should be applied.
    final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
    if (transformTypesObj == null) {
        return;
    }
    @SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
    if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
        try {
            result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
        try {
            result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.ERROR_RESULT)) {
        result.setResult(new BindResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS, null));
    }
    if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
        throw new RuntimeException();
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) EnumSet(java.util.EnumSet) Set(java.util.Set) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) BindResult(com.unboundid.ldap.sdk.BindResult) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Example 40 with IntermediateResponse

use of com.unboundid.ldap.sdk.IntermediateResponse in project ldapsdk by pingidentity.

the class ControlBasedOperationInterceptor method processSASLBindResult.

/**
 * {@inheritDoc}
 */
@Override()
public void processSASLBindResult(final InMemoryInterceptedSASLBindResult result) {
    // See if there are any transformations that should be applied.
    final Object transformTypesObj = result.getProperty(STATE_KEY_TRANSFORM_TYPES);
    if (transformTypesObj == null) {
        return;
    }
    @SuppressWarnings("unchecked") final Set<TransformType> transformTypes = (Set<TransformType>) transformTypesObj;
    if (transformTypes.contains(TransformType.INJECT_INTERMEDIATE_RESPONSE)) {
        try {
            result.sendIntermediateResponse(new IntermediateResponse(INTERMEDIATE_RESPONSE_OID, new ASN1OctetString("Injected in Response")));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.INJECT_UNSOLICITED_NOTIFICATION)) {
        try {
            result.sendUnsolicitedNotification(new ExtendedResult(0, ResultCode.SUCCESS, "Injected by Result", null, null, UNSOLICITED_NOTIFICATION_OID, null, null));
        } catch (final Exception e) {
        }
    }
    if (transformTypes.contains(TransformType.ERROR_RESULT)) {
        result.setResult(new BindResult(result.getMessageID(), ResultCode.UNWILLING_TO_PERFORM, "Error result by transformation", null, StaticUtils.NO_STRINGS, StaticUtils.NO_CONTROLS, null));
    }
    if (transformTypes.contains(TransformType.RESULT_RUNTIME_EXCEPTION)) {
        throw new RuntimeException();
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) IntermediateResponse(com.unboundid.ldap.sdk.IntermediateResponse) EnumSet(java.util.EnumSet) Set(java.util.Set) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) BindResult(com.unboundid.ldap.sdk.BindResult) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Aggregations

IntermediateResponse (com.unboundid.ldap.sdk.IntermediateResponse)56 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)39 Test (org.testng.annotations.Test)37 EnumSet (java.util.EnumSet)19 Set (java.util.Set)19 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)18 LDAPException (com.unboundid.ldap.sdk.LDAPException)18 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)12 Control (com.unboundid.ldap.sdk.Control)11 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)6 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)5 ASN1Element (com.unboundid.asn1.ASN1Element)2 AddRequest (com.unboundid.ldap.sdk.AddRequest)2 BindResult (com.unboundid.ldap.sdk.BindResult)2 Entry (com.unboundid.ldap.sdk.Entry)2 SearchResultReference (com.unboundid.ldap.sdk.SearchResultReference)2 AddRequestProtocolOp (com.unboundid.ldap.protocol.AddRequestProtocolOp)1 IntermediateResponseProtocolOp (com.unboundid.ldap.protocol.IntermediateResponseProtocolOp)1 CompareRequest (com.unboundid.ldap.sdk.CompareRequest)1 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)1