Update the LDAPSearch, LDAPModify, LDAPCompare, and LDAPDelete tools to rename
the "--controls" argument to "--control", since each instance only allows the
user to specify information about a single control. Issue #1009.
Update the LDAPSearch, LDAPModify, LDAPCompare, and LDAPDelete tools to allow
multiple instances of the "-J"/"--control" argument to specify multiple
arbitrary controls. Issue #1010.
| | |
| | | argParser.addArgument(assertionFilter); |
| | | |
| | | controlStr = |
| | | new StringArgument("controls", 'J', "controls", false, false, true, |
| | | new StringArgument("control", 'J', "control", false, true, true, |
| | | "{controloid[:criticality[:value|::b64value|:<filePath]]}", |
| | | null, null, MSGID_DESCRIPTION_CONTROLS); |
| | | argParser.addArgument(controlStr); |
| | |
| | | compareOptions.setVerbose(verbose.isPresent()); |
| | | compareOptions.setContinueOnError(continueOnError.isPresent()); |
| | | compareOptions.setEncoding(encodingStr.getValue()); |
| | | if(controlStr.hasValue()) |
| | | |
| | | if(controlStr.isPresent()) |
| | | { |
| | | String ctrlString = controlStr.getValue(); |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | for (String ctrlString : controlStr.getValues()) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | compareOptions.getControls().add(ctrl); |
| | | } |
| | | compareOptions.getControls().add(ctrl); |
| | | } |
| | | |
| | | if (assertionFilter.isPresent()) |
| | |
| | | argParser.addArgument(deleteSubtree); |
| | | |
| | | controlStr = |
| | | new StringArgument("controls", 'J', "controls", false, false, true, |
| | | new StringArgument("control", 'J', "control", false, true, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | | null, null, MSGID_DESCRIPTION_CONTROLS); |
| | | argParser.addArgument(controlStr); |
| | |
| | | deleteOptions.setContinueOnError(continueOnError.isPresent()); |
| | | deleteOptions.setEncoding(encodingStr.getValue()); |
| | | deleteOptions.setDeleteSubtree(deleteSubtree.isPresent()); |
| | | if(controlStr.hasValue()) |
| | | |
| | | if(controlStr.isPresent()) |
| | | { |
| | | String ctrlString = controlStr.getValue(); |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | for (String ctrlString : controlStr.getValues()) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | deleteOptions.getControls().add(ctrl); |
| | | } |
| | | deleteOptions.getControls().add(ctrl); |
| | | } |
| | | |
| | | if(deleteOptions.getDeleteSubtree()) |
| | | { |
| | | LDAPControl control = new LDAPControl(OID_SUBTREE_DELETE_CONTROL); |
| | |
| | | argParser.addArgument(postReadAttributes); |
| | | |
| | | controlStr = |
| | | new StringArgument("controls", 'J', "controls", false, false, true, |
| | | new StringArgument("control", 'J', "control", false, true, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | | null, null, MSGID_DESCRIPTION_CONTROLS); |
| | | argParser.addArgument(controlStr); |
| | |
| | | modifyOptions.setContinueOnError(continueOnError.isPresent()); |
| | | modifyOptions.setEncoding(encodingStr.getValue()); |
| | | modifyOptions.setDefaultAdd(defaultAdd.isPresent()); |
| | | if(controlStr.hasValue()) |
| | | |
| | | if (controlStr.isPresent()) |
| | | { |
| | | String ctrlString = controlStr.getValue(); |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | for (String ctrlString : controlStr.getValues()) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | modifyOptions.getControls().add(ctrl); |
| | | } |
| | | modifyOptions.getControls().add(ctrl); |
| | | } |
| | | |
| | | if (proxyAuthzID.isPresent()) |
| | |
| | | argParser.addArgument(matchedValuesFilter); |
| | | |
| | | controlStr = |
| | | new StringArgument("controls", 'J', "controls", false, false, true, |
| | | new StringArgument("control", 'J', "control", false, true, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | | null, null, MSGID_DESCRIPTION_CONTROLS); |
| | | argParser.addArgument(controlStr); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | if(controlStr.hasValue()) |
| | | if(controlStr.isPresent()) |
| | | { |
| | | String ctrlString = controlStr.getValue(); |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | for (String ctrlString : controlStr.getValues()) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | int msgID = MSGID_TOOL_INVALID_CONTROL_STRING; |
| | | String message = getMessage(msgID, ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | searchOptions.getControls().add(ctrl); |
| | | } |
| | | searchOptions.getControls().add(ctrl); |
| | | } |
| | | |
| | | if (proxyAuthzID.isPresent()) |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests the inclusion of multiple arbitrary controls in the request to the |
| | | * server. |
| | | * |
| | | * @throws Exception If an unexpectd problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testMultipleRequestControls() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", OID_MANAGE_DSAIT_CONTROL + ":false", |
| | | "-J", OID_SUBTREE_DELETE_CONTROL + ":true", |
| | | "o=test" |
| | | }; |
| | | |
| | | assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the LDAPDelete tool with the "--help" option. |
| | | */ |
| | | @Test() |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests the inclusion of multiple arbitrary controls in the request to the |
| | | * server. |
| | | * |
| | | * @throws Exception If an unexpectd problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testMultipleRequestControls() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | "dn: o=test", |
| | | "changetype: delete"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", OID_MANAGE_DSAIT_CONTROL + ":false", |
| | | "-J", OID_SUBTREE_DELETE_CONTROL + ":true", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests with various forms of malformed LDIF changes. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests the inclusion of multiple arbitrary controls in the request to the |
| | | * server. |
| | | * |
| | | * @throws Exception If an unexpectd problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testMultipleRequestControls() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-b", "o=test", |
| | | "-s", "base", |
| | | "-J", OID_ACCOUNT_USABLE_CONTROL + ":true", |
| | | "-J", OID_MANAGE_DSAIT_CONTROL + ":false", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the LDAPSearch tool with the "--help" option. |
| | | */ |
| | | @Test() |