Search in sources :

Example 6 with DeleteResponseProtocolOp

use of com.unboundid.ldap.protocol.DeleteResponseProtocolOp in project ldapsdk by pingidentity.

the class LDAPDebuggerTestCase method testSuccessfulDelete.

/**
 * Provides test coverage for a successful delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSuccessfulDelete() throws Exception {
    TestRequestHandler.setReturnOp(new DeleteResponseProtocolOp(0, null, null, null));
    final DeleteRequest r = new DeleteRequest("dc=example,dc=com");
    r.addControl(new Control("1.2.3.4"));
    conn.delete(r);
}
Also used : AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) DeleteResponseProtocolOp(com.unboundid.ldap.protocol.DeleteResponseProtocolOp) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) Test(org.testng.annotations.Test)

Example 7 with DeleteResponseProtocolOp

use of com.unboundid.ldap.protocol.DeleteResponseProtocolOp in project ldapsdk by pingidentity.

the class LDAPDebuggerTestCase method testFailedDelete.

/**
 * Provides test coverage for a failed delete operation.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testFailedDelete() throws Exception {
    TestRequestHandler.setReturnOp(new DeleteResponseProtocolOp(32, "dc=example,dc=com", "msg", Arrays.asList("ldap://server1.example.com/dc=example,dc=com", "ldap://server2.example.com/dc=example,dc=com")));
    conn.delete("dc=example,dc=com");
}
Also used : DeleteResponseProtocolOp(com.unboundid.ldap.protocol.DeleteResponseProtocolOp) Test(org.testng.annotations.Test)

Example 8 with DeleteResponseProtocolOp

use of com.unboundid.ldap.protocol.DeleteResponseProtocolOp in project ldapsdk by pingidentity.

the class CannedResponseRequestHandlerTestCase method testDefaultConstructor.

/**
 * Tests the behavior of the request handler with the default configuration.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDefaultConstructor() throws Exception {
    final CannedResponseRequestHandler handler = new CannedResponseRequestHandler().newInstance(null);
    LDAPMessage m = handler.processAddRequest(1, new AddRequestProtocolOp("dc=example,dc=com", Arrays.asList(new Attribute("objectClass", "top", "domain"), new Attribute("dc", "example"))), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 1);
    assertTrue(m.getProtocolOp() instanceof AddResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processBindRequest(2, new BindRequestProtocolOp("uid=admin,dc=example,dc=com", "password"), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 2);
    assertTrue(m.getProtocolOp() instanceof BindResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processCompareRequest(3, new CompareRequestProtocolOp("dc=example,dc=com", "objectClass", new ASN1OctetString("top")), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 3);
    assertTrue(m.getProtocolOp() instanceof CompareResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processDeleteRequest(4, new DeleteRequestProtocolOp("dc=example,dc=com"), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 4);
    assertTrue(m.getProtocolOp() instanceof DeleteResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processExtendedRequest(5, new ExtendedRequestProtocolOp("1.2.3.4", null), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 5);
    assertTrue(m.getProtocolOp() instanceof ExtendedResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processModifyRequest(6, new ModifyRequestProtocolOp("dc=example,dc=com", Arrays.asList(new Modification(ModificationType.REPLACE, "description", "foo"))), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 6);
    assertTrue(m.getProtocolOp() instanceof ModifyResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processModifyDNRequest(6, new ModifyDNRequestProtocolOp("ou=People,dc=example,dc=com", "ou=Users", true, null), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 6);
    assertTrue(m.getProtocolOp() instanceof ModifyDNResponseProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
    m = handler.processSearchRequest(7, new SearchRequestProtocolOp("dc=example,dc=com", SearchScope.SUB, DereferencePolicy.NEVER, 0, 0, false, Filter.createEqualityFilter("uid", "test"), Arrays.<String>asList()), Collections.<Control>emptyList());
    assertNotNull(m);
    assertEquals(m.getMessageID(), 7);
    assertTrue(m.getProtocolOp() instanceof SearchResultDoneProtocolOp);
    assertNotNull(m.getControls());
    assertTrue(m.getControls().isEmpty());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Modification(com.unboundid.ldap.sdk.Modification) ExtendedResponseProtocolOp(com.unboundid.ldap.protocol.ExtendedResponseProtocolOp) Attribute(com.unboundid.ldap.sdk.Attribute) SearchRequestProtocolOp(com.unboundid.ldap.protocol.SearchRequestProtocolOp) AddRequestProtocolOp(com.unboundid.ldap.protocol.AddRequestProtocolOp) CompareRequestProtocolOp(com.unboundid.ldap.protocol.CompareRequestProtocolOp) DeleteResponseProtocolOp(com.unboundid.ldap.protocol.DeleteResponseProtocolOp) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) AddResponseProtocolOp(com.unboundid.ldap.protocol.AddResponseProtocolOp) BindRequestProtocolOp(com.unboundid.ldap.protocol.BindRequestProtocolOp) ModifyDNResponseProtocolOp(com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp) ExtendedRequestProtocolOp(com.unboundid.ldap.protocol.ExtendedRequestProtocolOp) DeleteRequestProtocolOp(com.unboundid.ldap.protocol.DeleteRequestProtocolOp) ModifyRequestProtocolOp(com.unboundid.ldap.protocol.ModifyRequestProtocolOp) Control(com.unboundid.ldap.sdk.Control) BindResponseProtocolOp(com.unboundid.ldap.protocol.BindResponseProtocolOp) ModifyDNRequestProtocolOp(com.unboundid.ldap.protocol.ModifyDNRequestProtocolOp) SearchResultDoneProtocolOp(com.unboundid.ldap.protocol.SearchResultDoneProtocolOp) CompareResponseProtocolOp(com.unboundid.ldap.protocol.CompareResponseProtocolOp) ModifyResponseProtocolOp(com.unboundid.ldap.protocol.ModifyResponseProtocolOp) Test(org.testng.annotations.Test)

Example 9 with DeleteResponseProtocolOp

use of com.unboundid.ldap.protocol.DeleteResponseProtocolOp in project ldapsdk by pingidentity.

the class LDAPDebuggerRequestHandler method processDeleteRequest.

/**
 * {@inheritDoc}
 */
@Override()
@NotNull()
public LDAPMessage processDeleteRequest(final int messageID, @NotNull final DeleteRequestProtocolOp request, @NotNull final List<Control> controls) {
    final StringBuilder b = getBuffer();
    appendHeader(b, messageID);
    b.append("     Delete Request Protocol Op:").append(StaticUtils.EOL);
    b.append("          DN:  ").append(request.getDN()).append(StaticUtils.EOL);
    appendControls(b, controls);
    logHandler.publish(new LogRecord(Level.INFO, b.toString()));
    logHandler.flush();
    final LDAPMessage responseMessage = requestHandler.processDeleteRequest(messageID, request, controls);
    b.setLength(0);
    appendHeader(b, responseMessage.getMessageID());
    b.append("     Delete Response Protocol Op:").append(StaticUtils.EOL);
    final DeleteResponseProtocolOp protocolOp = responseMessage.getDeleteResponseProtocolOp();
    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) DeleteResponseProtocolOp(com.unboundid.ldap.protocol.DeleteResponseProtocolOp) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) NotNull(com.unboundid.util.NotNull)

Example 10 with DeleteResponseProtocolOp

use of com.unboundid.ldap.protocol.DeleteResponseProtocolOp in project ldapsdk by pingidentity.

the class InMemoryRequestHandler method delete.

/**
 * Processes the provided delete request.
 * <BR><BR>
 * This method may be used regardless of whether the server is listening for
 * client connections, and regardless of whether delete operations are
 * allowed in the server.
 *
 * @param  deleteRequest  The delete request to be processed.  It must not be
 *                        {@code null}.
 *
 * @return  The result of processing the delete operation.
 *
 * @throws  LDAPException  If the server rejects the delete request, or if a
 *                         problem is encountered while sending the request or
 *                         reading the response.
 */
@NotNull()
public LDAPResult delete(@NotNull final DeleteRequest deleteRequest) throws LDAPException {
    final ArrayList<Control> requestControlList = new ArrayList<>(deleteRequest.getControlList());
    requestControlList.add(new Control(OID_INTERNAL_OPERATION_REQUEST_CONTROL, false));
    final LDAPMessage responseMessage = processDeleteRequest(1, new DeleteRequestProtocolOp(deleteRequest.getDN()), requestControlList);
    final DeleteResponseProtocolOp deleteResponse = responseMessage.getDeleteResponseProtocolOp();
    final LDAPResult ldapResult = new LDAPResult(responseMessage.getMessageID(), ResultCode.valueOf(deleteResponse.getResultCode()), deleteResponse.getDiagnosticMessage(), deleteResponse.getMatchedDN(), deleteResponse.getReferralURLs(), responseMessage.getControls());
    switch(deleteResponse.getResultCode()) {
        case ResultCode.SUCCESS_INT_VALUE:
        case ResultCode.NO_OPERATION_INT_VALUE:
            return ldapResult;
        default:
            throw new LDAPException(ldapResult);
    }
}
Also used : VirtualListViewRequestControl(com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) RFC3672SubentriesRequestControl(com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) VirtualListViewResponseControl(com.unboundid.ldap.sdk.controls.VirtualListViewResponseControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) DraftZeilengaLDAPNoOp12RequestControl(com.unboundid.ldap.sdk.experimental.DraftZeilengaLDAPNoOp12RequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) ServerSideSortResponseControl(com.unboundid.ldap.sdk.controls.ServerSideSortResponseControl) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) AuthorizationIdentityResponseControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) ServerSideSortRequestControl(com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) DontUseCopyRequestControl(com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) DeleteResponseProtocolOp(com.unboundid.ldap.protocol.DeleteResponseProtocolOp) ArrayList(java.util.ArrayList) LDAPMessage(com.unboundid.ldap.protocol.LDAPMessage) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) DeleteRequestProtocolOp(com.unboundid.ldap.protocol.DeleteRequestProtocolOp) NotNull(com.unboundid.util.NotNull)

Aggregations

DeleteResponseProtocolOp (com.unboundid.ldap.protocol.DeleteResponseProtocolOp)13 LDAPMessage (com.unboundid.ldap.protocol.LDAPMessage)10 NotNull (com.unboundid.util.NotNull)8 LDAPException (com.unboundid.ldap.sdk.LDAPException)7 Control (com.unboundid.ldap.sdk.Control)6 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)4 AddResponseProtocolOp (com.unboundid.ldap.protocol.AddResponseProtocolOp)4 ModifyDNResponseProtocolOp (com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp)4 ModifyResponseProtocolOp (com.unboundid.ldap.protocol.ModifyResponseProtocolOp)4 DeleteRequestProtocolOp (com.unboundid.ldap.protocol.DeleteRequestProtocolOp)3 ExtendedResponseProtocolOp (com.unboundid.ldap.protocol.ExtendedResponseProtocolOp)3 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)3 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)3 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)3 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)3 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)3 BindResponseProtocolOp (com.unboundid.ldap.protocol.BindResponseProtocolOp)2 CompareResponseProtocolOp (com.unboundid.ldap.protocol.CompareResponseProtocolOp)2 SearchResultDoneProtocolOp (com.unboundid.ldap.protocol.SearchResultDoneProtocolOp)2