OPENDJ-2773 Remove duplicated server tools
Once sdk ldap toolkit tools have been merged with the server ones, we are now able to remove the following tools from opendj-server-legacy module:
* base64
* Removes whole class. Replaced by SDK's Base64 which is noew public
* ldapcompare
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* ldapdelete
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* ldapmodify
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* Removes -a option since it does not exist in the sdk because it's the default behavior
* Removes support of ChangeNumber control decoding and printing since it was a specific DJ one.
* ldappasswordmodify
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* When noop control is used, tool return code is now 0 instead of 16654, apdats unit test in consequence.
* ldapsearch
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* Replace -r argument by -o mech=EXTERNAL because -r has been removed in the sdk
* Always use -N argument to provide client certificate nickname ('client-cert' in unit tests) when -o mech=EXTERNAL (SASL external Bind) is used since the server default behavior to take the first client certificate from the client keystore has not been keeped.
* When SSL is used in used tests we do not have hostname matching between certificate's cn (cn=OpenDJ Server Certificate) and the one given in ldap* tool -h argument (127.0.0.1).
SDK tools prompts user to know what they want to do in such cases (if the -X, --trustAll flag has not been provided on the command line). Modified impacted unit tests to trust the certificate for the session only. As it's the default value, we just need to hit enter key on stdin.
* We do not support -o mech=ANONYMOUS in the sdk. So this parameter has been removed from server's unit tests.
* ldif* tools
* Removes whole class and adapts test cases usages to the sdk ldapcompare options
* Changes performed in source code files to avoid depending on opendj-ldap-toolkit.jar
* ConfigurationHandler.java
* Use sdk LDIF* apis to perform the modify instead of the tool.
* NewBaseDNPanel.java
* Use ldapmodify script located under in bin/ folder instead of programmatically. This is way no ideal but this code is so difficult to manage as it's a best effort situation here.
* src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
* Use sdk connection to perform the password modify extended request instead of using the tool.
* opendj-server-legacy/pom.xml
* Add a dependency on opendj-ldap-toolkit.
Note that transitive dependancies are correctly moved in the lib/ archive folder and bootstrap-client jar is correcly updated.
34 files deleted
1 files added
82 files modified
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * For example, the JDK encoder does not handle array/offset/len parameters, and |
| | | * the decoder ignores invalid Base64 data. |
| | | */ |
| | | final class Base64 { |
| | | public final class Base64 { |
| | | /** |
| | | * The set of characters that may be used in base64-encoded values. |
| | | */ |
| | |
| | | * @throws NullPointerException |
| | | * If {@code base64} was {@code null}. |
| | | */ |
| | | static ByteString decode(final String base64) { |
| | | public static ByteString decode(final String base64) { |
| | | Reject.ifNull(base64); |
| | | |
| | | // The encoded value must have length that is a multiple of four |
| | |
| | | * @throws NullPointerException |
| | | * If {@code bytes} was {@code null}. |
| | | */ |
| | | static String encode(final ByteSequence bytes) { |
| | | public static String encode(final byte[] bytes) { |
| | | return encode(ByteString.wrap(bytes)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Encodes the provided data as a base64 string. |
| | | * |
| | | * @param bytes |
| | | * The data to be encoded. |
| | | * @return The base64 encoded representation of {@code bytes}. |
| | | * @throws NullPointerException |
| | | * If {@code bytes} was {@code null}. |
| | | */ |
| | | public static String encode(final ByteSequence bytes) { |
| | | Reject.ifNull(bytes); |
| | | |
| | | if (bytes.isEmpty()) { |
| New file |
| | |
| | | /* |
| | | * The contents of this file are subject to the terms of the Common Development and |
| | | * Distribution License (the License). You may not use this file except in compliance with the |
| | | * License. |
| | | * |
| | | * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the |
| | | * specific language governing permission and limitations under the License. |
| | | * |
| | | * When distributing Covered Software, include this CDDL Header Notice in each file and include |
| | | * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static org.fest.assertions.Assertions.*; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** This class defines a set of tests for the {@link org.forgerock.opendj.ldap.Base64} class. */ |
| | | public final class TestBase64 extends SdkTestCase { |
| | | /** Look up table for converting hex chars to byte values. */ |
| | | private static final byte[] HEX_TO_BYTE = { -1, -1, -1, -1, -1, -1, -1, -1, |
| | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| | | -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, |
| | | -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, |
| | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| | | -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1 - 1, |
| | | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; |
| | | |
| | | /** |
| | | * Base 64 valid test data provider. |
| | | * |
| | | * @return Returns an array of decoded and valid encoded base64 data. |
| | | */ |
| | | @DataProvider(name = "validData") |
| | | public Object[][] createValidData() { |
| | | return new Object[][] { |
| | | { "", "" }, |
| | | { "00", "AA==" }, |
| | | { "01", "AQ==" }, |
| | | { "02", "Ag==" }, |
| | | { "03", "Aw==" }, |
| | | { "04", "BA==" }, |
| | | { "05", "BQ==" }, |
| | | { "06", "Bg==" }, |
| | | { "07", "Bw==" }, |
| | | { "0000", "AAA=" }, |
| | | { "000000", "AAAA" }, |
| | | { "00000000", "AAAAAA==" }, |
| | | { |
| | | "000102030405060708090a0b0c0d0e0f" |
| | | + "101112131415161718191a1b1c1d1e1f" |
| | | + "202122232425262728292a2b2c2d2e2f" |
| | | + "303132333435363738393a3b3c3d3e3f" |
| | | + "404142434445464748494a4b4c4d4e4f" |
| | | + "505152535455565758595a5b5c5d5e5f" |
| | | + "606162636465666768696a6b6c6d6e6f" |
| | | + "707172737475767778797a7b7c7d7e7f" |
| | | + "808182838485868788898a8b8c8d8e8f" |
| | | + "909192939495969798999a9b9c9d9e9f" |
| | | + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" |
| | | + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" |
| | | + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" |
| | | + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" |
| | | + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" |
| | | + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", |
| | | |
| | | "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4v" |
| | | + "MDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5f" |
| | | + "YGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6P" |
| | | + "kJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/" |
| | | + "wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v" |
| | | + "8PHy8/T19vf4+fr7/P3+/w==" |
| | | }, |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Base 64 invalid test data provider. |
| | | * |
| | | * @return Returns an array of invalid encoded base64 data. |
| | | */ |
| | | @DataProvider(name = "invalidData") |
| | | public Object[][] createInvalidData() { |
| | | // FIXME: fix cases ==== and ==x= |
| | | |
| | | return new Object[][] { { "=" }, { "==" }, { "===" }, { "A" }, |
| | | { "AA" }, { "AAA" }, { "AA`=" }, { "AA~=" }, { "AA!=" }, |
| | | { "AA@=" }, { "AA#=" }, { "AA$=" }, { "AA%=" }, { "AA^=" }, |
| | | { "AA*=" }, { "AA(=" }, { "AA)=" }, { "AA_=" }, { "AA-=" }, |
| | | { "AA{=" }, { "AA}=" }, { "AA|=" }, { "AA[=" }, { "AA]=" }, |
| | | { "AA\\=" }, { "AA;=" }, { "AA'=" }, { "AA\"=" }, { "AA:=" }, |
| | | { "AA,=" }, { "AA.=" }, { "AA<=" }, { "AA>=" }, { "AA?=" }, |
| | | { "AA;=" } }; |
| | | } |
| | | |
| | | /** |
| | | * Tests the encode method. |
| | | * |
| | | * @param hexData |
| | | * The decoded hex data. |
| | | * @param encodedData |
| | | * The encoded data. |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test(dataProvider = "validData") |
| | | public void testEncode(final String hexData, final String encodedData) throws Exception { |
| | | assertThat(Base64.encode(getBytes(hexData))).isEqualTo(encodedData); |
| | | } |
| | | |
| | | /** |
| | | * Tests the decode method against valid data. |
| | | * |
| | | * @param hexData |
| | | * The decoded hex data. |
| | | * @param encodedData |
| | | * The encoded data. |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test(dataProvider = "validData") |
| | | public void testDecodeValidData(final String hexData, final String encodedData) throws Exception { |
| | | assertThat(Base64.decode(encodedData).toByteArray()).isEqualTo(getBytes(hexData)); |
| | | } |
| | | |
| | | /** |
| | | * Tests the decode method against invalid data. |
| | | * |
| | | * @param encodedData |
| | | * The invalid encoded data. |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test(dataProvider = "invalidData", |
| | | expectedExceptions = LocalizedIllegalArgumentException.class, |
| | | expectedExceptionsMessageRegExp = ".*cannot be base64-decoded.*") |
| | | public void testDecodeInvalidData(String encodedData) throws Exception { |
| | | Base64.decode(encodedData).toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * Decode a hex string to a byte-array. |
| | | * |
| | | * @param hexData |
| | | * The string of hex. |
| | | * @return Returns the decoded byte array. |
| | | */ |
| | | private byte[] getBytes(String hexData) { |
| | | int sz = hexData.length(); |
| | | |
| | | if (sz % 2 != 0) { |
| | | throw new IllegalArgumentException("Hex string does not contain an even number of hex digits"); |
| | | } |
| | | |
| | | byte[] bytes = new byte[sz / 2]; |
| | | |
| | | for (int i = 0, j = 0; i < sz; i += 2, j++) { |
| | | int c = hexData.codePointAt(i); |
| | | if ((c & 0x7f) != c) { |
| | | throw new IllegalArgumentException("Hex string contains non-hex digits"); |
| | | } |
| | | |
| | | byte b1 = HEX_TO_BYTE[c]; |
| | | if (b1 < 0) { |
| | | throw new IllegalArgumentException("Hex string contains non-hex digits"); |
| | | } |
| | | |
| | | c = hexData.codePointAt(i + 1); |
| | | if ((c & 0x7f) != c) { |
| | | throw new IllegalArgumentException("Hex string contains non-hex digits"); |
| | | } |
| | | |
| | | byte b2 = HEX_TO_BYTE[c]; |
| | | if (b2 < 0) { |
| | | throw new IllegalArgumentException("Hex string contains non-hex digits"); |
| | | } |
| | | |
| | | bytes[j] = (byte) ((b1 << 4) | b2); |
| | | } |
| | | |
| | | return bytes; |
| | | } |
| | | } |
| | |
| | | import java.io.OutputStream; |
| | | import java.io.StringReader; |
| | | import java.net.URL; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Enumeration; |
| | | import java.util.HashSet; |
| | |
| | | import javax.xml.validation.SchemaFactory; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.tools.SSLConnectionException; |
| | | import org.opends.server.tools.SSLConnectionFactory; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.util.Base64; |
| | | import org.w3c.dom.Document; |
| | | import org.xml.sax.Attributes; |
| | | import org.xml.sax.EntityResolver; |
| | |
| | | authenticationInHeader = true; |
| | | String authorization = headerVal.substring(6).trim(); |
| | | try { |
| | | String unencoded = new String(Base64.decode(authorization)); |
| | | String unencoded = new String(Base64.decode(authorization).toByteArray()); |
| | | int colon = unencoded.indexOf(':'); |
| | | if (colon > 0) { |
| | | if (useHTTPAuthzID) |
| | |
| | | } |
| | | bindPassword = unencoded.substring(colon + 1); |
| | | } |
| | | } catch (ParseException ex) { |
| | | } catch (final LocalizedIllegalArgumentException ex) { |
| | | // user/DN:password parsing error |
| | | batchResponses.add( |
| | | createErrorResponse(objFactory, |
| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-ldap-toolkit</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.forgerock</groupId> |
| | | <artifactId>forgerock-build-tools</artifactId> |
| | | </dependency> |
| | |
| | | import java.text.ParseException; |
| | | import java.util.Objects; |
| | | |
| | | import org.opends.server.util.Base64; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | |
| | | /** |
| | | * Class used to represent Binary Values. This is required in particular |
| | |
| | | { |
| | | if (bytes == null && base64 != null) |
| | | { |
| | | bytes = Base64.decode(base64); |
| | | bytes = Base64.decode(base64).toByteArray(); |
| | | } |
| | | return bytes; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.requests.PasswordModifyExtendedRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.forgerock.opendj.ldap.requests.SearchRequest; |
| | | import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldif.ConnectionEntryReader; |
| | | import org.forgerock.util.promise.ExceptionHandler; |
| | | import org.forgerock.util.promise.ResultHandler; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.browser.ConnectionWithControls; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | |
| | | /** The task called when we want to reset the password of the user. */ |
| | | public class ResetUserPasswordTask extends Task |
| | |
| | | { |
| | | state = State.RUNNING; |
| | | lastException = null; |
| | | try |
| | | { |
| | | List<String> arguments = getCommandLineArguments(); |
| | | String[] args = arguments.toArray(new String[arguments.size()]); |
| | | |
| | | returnCode = LDAPPasswordModify.mainPasswordModify(args, false, |
| | | outPrintStream, errorPrintStream); |
| | | |
| | | if (returnCode != 0) |
| | | final ConnectionWrapper connectionWrapper = useAdminCtx ? getInfo().getConnection() |
| | | : getInfo().getUserDataConnection(); |
| | | if (!isServerRunning() || connectionWrapper == null) |
| | | { |
| | | // Fail fast impossible to connect to the server. |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | | final PasswordModifyExtendedRequest passwordModifyRequest = Requests.newPasswordModifyExtendedRequest(); |
| | | if (currentPassword == null) |
| | | { |
| | | passwordModifyRequest.setUserIdentity("dn: " + dn); |
| | | } |
| | | else |
| | | { |
| | | if (lastException == null && currentPassword != null) |
| | | { |
| | | // The connections must be updated, just update the environment, which |
| | | // is what we use to clone connections and to launch scripts. |
| | | // The environment will also be used if we want to reconnect. |
| | | rebind(getInfo().getConnection()); |
| | | if (getInfo().getUserDataConnection() != null) |
| | | { |
| | | rebind(getInfo().getUserDataConnection()); |
| | | } |
| | | } |
| | | state = State.FINISHED_SUCCESSFULLY; |
| | | passwordModifyRequest.setOldPassword(currentPassword); |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | lastException = t; |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | | passwordModifyRequest.setNewPassword(newPassword); |
| | | connectionWrapper.getConnection() |
| | | .extendedRequestAsync(passwordModifyRequest) |
| | | .thenOnResultOrException( |
| | | new ResultHandler<PasswordModifyExtendedResult>() |
| | | { |
| | | @Override |
| | | public void handleResult(final PasswordModifyExtendedResult passwordModifyExtendedResult) |
| | | { |
| | | if (lastException == null && currentPassword != null) |
| | | { |
| | | try |
| | | { |
| | | // The connections must be updated, just update the environment, which |
| | | // is what we use to clone connections and to launch scripts. |
| | | // The environment will also be used if we want to reconnect. |
| | | rebind(getInfo().getConnection()); |
| | | if (getInfo().getUserDataConnection() != null) |
| | | { |
| | | rebind(getInfo().getUserDataConnection()); |
| | | } |
| | | } |
| | | catch (final LdapException e) |
| | | { |
| | | lastException = e; |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | | } |
| | | state = State.FINISHED_SUCCESSFULLY; |
| | | } |
| | | }, |
| | | new ExceptionHandler<LdapException>() |
| | | { |
| | | @Override |
| | | public void handleException(final LdapException e) |
| | | { |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void rebind(ConnectionWrapper conn) throws LdapException |
| | |
| | | "list-backends", "manage-account", "manage-tasks", "restore.online", |
| | | "stop-ds", "status", "control-panel", "uninstall", "setup", |
| | | "backup.offline", "encode-password", "export-ldif.offline", |
| | | "ldif-diff", "ldifmodify", "ldifsearch", "makeldif", |
| | | "ldifdiff", "ldifmodify", "ldifsearch", "makeldif", |
| | | "rebuild-index", "restore.offline", "upgrade", |
| | | "verify-index", "backendstat" |
| | | ); |
| | | private final Set<String> relevantScriptNames = newHashSet( |
| | | "start-ds", "import-ldif.offline", "backup.offline", |
| | | "export-ldif.offline", |
| | | "ldif-diff", "makeldif", "rebuild-index", "restore.offline", |
| | | "ldifdiff", "makeldif", "rebuild-index", "restore.offline", |
| | | "verify-index", "backendstat" |
| | | ); |
| | | |
| | |
| | | import org.opends.server.tools.BackendTypeHelper; |
| | | import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter; |
| | | import org.opends.server.tools.ImportLDIF; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.makeldif.EntryWriter; |
| | | import org.opends.server.tools.makeldif.MakeLDIFException; |
| | | import org.opends.server.tools.makeldif.TemplateEntry; |
| | |
| | | else |
| | | { |
| | | // If we are not local, we use ldapmodify to update the contents. |
| | | args.add("-a"); |
| | | args.add("-f"); |
| | | args.add(ldifFile); |
| | | } |
| | |
| | | } |
| | | try |
| | | { |
| | | if (isServerRunning()) |
| | | if (isServerRunning() && (isLocal() || importLDIF)) |
| | | { |
| | | if (isLocal() || importLDIF) |
| | | { |
| | | returnCode = ImportLDIF.mainImportLDIF(args, false, outPrintStream, errorPrintStream); |
| | | } |
| | | else |
| | | { |
| | | returnCode = LDAPModify.mainModify(args, false, outPrintStream, errorPrintStream); |
| | | } |
| | | returnCode = ImportLDIF.mainImportLDIF(args, false, outPrintStream, errorPrintStream); |
| | | } |
| | | else |
| | | { |
| | |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.Attribute; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | /** |
| | | * Abstract class containing code shared by the different LDAP entry view |
| | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.security.MessageDigest; |
| | |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldif.EntryReader; |
| | | import org.forgerock.opendj.ldif.LDIF; |
| | | import org.forgerock.opendj.ldif.LDIFChangeRecordReader; |
| | | import org.forgerock.opendj.ldif.LDIFEntryReader; |
| | | import org.forgerock.opendj.ldif.LDIFEntryWriter; |
| | | import org.forgerock.util.Utils; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.tools.LDIFModify; |
| | | import org.opends.server.types.DirectoryEnvironmentConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void applyChangesFile(File sourceFile, File changesFile) throws IOException, LDIFException |
| | | { |
| | | // Create the appropriate LDIF readers and writer. |
| | | LDIFImportConfig sourceImportCfg = new LDIFImportConfig(sourceFile.getAbsolutePath()); |
| | | sourceImportCfg.setValidateSchema(false); |
| | | |
| | | LDIFImportConfig changesImportCfg = new LDIFImportConfig(changesFile.getAbsolutePath()); |
| | | changesImportCfg.setValidateSchema(false); |
| | | |
| | | String tempFile = changesFile.getAbsolutePath() + ".tmp"; |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(tempFile, ExistingFileBehavior.OVERWRITE); |
| | | |
| | | List<LocalizableMessage> errorList = new LinkedList<>(); |
| | | boolean successful; |
| | | try (LDIFReader sourceReader = new LDIFReader(sourceImportCfg); |
| | | LDIFReader changesReader = new LDIFReader(changesImportCfg); |
| | | LDIFWriter targetWriter = new LDIFWriter(exportConfig)) |
| | | final String tempFilePath = changesFile.getAbsolutePath() + ".tmp"; |
| | | try (final LDIFEntryReader sourceReader = new LDIFEntryReader(new FileReader(sourceFile)); |
| | | final LDIFChangeRecordReader changeRecordReader = new LDIFChangeRecordReader(new FileReader(changesFile)); |
| | | final LDIFEntryWriter ldifWriter = new LDIFEntryWriter(new FileWriter(tempFilePath))) |
| | | { |
| | | // Apply the changes and make sure there were no errors. |
| | | successful = LDIFModify.modifyLDIF(sourceReader, changesReader, targetWriter, errorList); |
| | | LDIF.copyTo(LDIF.patch(sourceReader, changeRecordReader), ldifWriter); |
| | | } |
| | | |
| | | if (!successful) |
| | | catch (final IOException e) |
| | | { |
| | | for (LocalizableMessage s : errorList) |
| | | { |
| | | logger.error(ERR_CONFIG_ERROR_APPLYING_STARTUP_CHANGE, s); |
| | | } |
| | | throw new LDIFException(ERR_CONFIG_UNABLE_TO_APPLY_CHANGES_FILE.get(Utils.joinAsString("; ", errorList))); |
| | | throw new LDIFException(ERR_CONFIG_UNABLE_TO_APPLY_CHANGES_FILE.get(e.getLocalizedMessage())); |
| | | } |
| | | |
| | | // Move the current config file out of the way and replace it with the updated version. |
| | |
| | | oldSource.delete(); |
| | | } |
| | | sourceFile.renameTo(oldSource); |
| | | new File(tempFile).renameTo(sourceFile); |
| | | new File(tempFilePath).renameTo(sourceFile); |
| | | |
| | | // Move the changes file out of the way so it doesn't get applied again. |
| | | File newChanges = new File(changesFile.getAbsolutePath() + ".applied"); |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.SelectableCertificateKeyManager; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | "jucN34MZwvzbmFHT/leUu3/cpykbGM9HL2QUX7iKvv2LJVqexhj7CLoXxZP" + |
| | | "oNL+HHKW0vi5/7W5KwOZsPqKI2SdYV7nDqTZklm5ZP0gmIuNO6mTqBRtC2D" + |
| | | "lplX1Iq+BrQJAmteiPtwhdZD+EIghe51CaseImjlLlY2ZK8w=="; |
| | | final byte[] certificate = Base64.decode(certificateBase64); |
| | | final byte[] certificate = Base64.decode(certificateBase64).toByteArray(); |
| | | final String keyID = getInstanceKeyID(certificate); |
| | | final SecretKey macKey = macCryptoManager.generateKeyEntry( |
| | | requestedMACAlgorithm, |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.AESPasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | { |
| | | ByteString decryptedPassword = |
| | | ByteString.wrap(cryptoManager.decrypt( |
| | | Base64.decode(storedPassword.toString()))); |
| | | Base64.decode(storedPassword.toString()).toByteArray())); |
| | | return plaintextPassword.equals(decryptedPassword); |
| | | } |
| | | catch (Exception e) |
| | |
| | | try |
| | | { |
| | | byte[] decryptedPassword = |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString())); |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | return ByteString.wrap(decryptedPassword); |
| | | } |
| | | catch (Exception e) |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.Base64PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | { |
| | | try |
| | | { |
| | | return ByteString.wrap(Base64.decode(storedPassword.toString())); |
| | | return ByteString.wrap(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.BlowfishPasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString decryptedPassword = |
| | | ByteString.wrap(cryptoManager.decrypt( |
| | | Base64.decode(storedPassword.toString()))); |
| | | return plaintextPassword.equals(decryptedPassword); |
| | | return plaintextPassword.equals(ByteString.wrap( |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()))); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | try |
| | | { |
| | | byte[] decryptedPassword = |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString())); |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | return ByteString.wrap(decryptedPassword); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.MD5PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | try |
| | | { |
| | | storedPWDigestBytes = |
| | | ByteString.wrap(Base64.decode(storedPassword.toString())); |
| | | ByteString.wrap(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | } |
| | | |
| | | final int iterations = Integer.parseInt(stored.substring(0, pos)); |
| | | byte[] decodedBytes = Base64.decode(stored.substring(pos + 1)); |
| | | byte[] decodedBytes = Base64.decode(stored.substring(pos + 1)).toByteArray(); |
| | | |
| | | final int saltLength = decodedBytes.length - SHA1_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | throw new Exception(); |
| | | } |
| | | int iterations = Integer.parseInt(authInfo.substring(0, pos)); |
| | | byte[] saltBytes = Base64.decode(authInfo.substring(pos + 1)); |
| | | byte[] digestBytes = Base64.decode(authValue); |
| | | byte[] saltBytes = Base64.decode(authInfo.substring(pos + 1)).toByteArray(); |
| | | byte[] digestBytes = Base64.decode(authValue).toByteArray(); |
| | | return encodeAndMatch(plaintextPassword, saltBytes, digestBytes, iterations); |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | try |
| | | { |
| | | String stored = storedPassword.toString(); |
| | | byte[] decodedBytes = Base64.decode(stored); |
| | | byte[] decodedBytes = Base64.decode(stored).toByteArray(); |
| | | |
| | | if (decodedBytes.length != NUM_SALT_BYTES + SHA1_LENGTH) |
| | | { |
| | |
| | | throw new Exception(); |
| | | } |
| | | int iterations = Integer.parseInt(authInfo.substring(0, pos)); |
| | | byte[] saltBytes = Base64.decode(authInfo.substring(pos + 1)); |
| | | byte[] digestBytes = Base64.decode(authValue); |
| | | byte[] saltBytes = Base64.decode(authInfo.substring(pos + 1)).toByteArray(); |
| | | byte[] digestBytes = Base64.decode(authValue).toByteArray(); |
| | | return encodeAndMatch(plaintextPassword, saltBytes, digestBytes, iterations); |
| | | } |
| | | catch (Exception e) |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.RC4PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString decryptedPassword = |
| | | ByteString.wrap(cryptoManager.decrypt( |
| | | Base64.decode(storedPassword.toString()))); |
| | | return plaintextPassword.equals(decryptedPassword); |
| | | return plaintextPassword.equals(ByteString.wrap( |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()))); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | try |
| | | { |
| | | byte[] decryptedPassword = |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString())); |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | return ByteString.wrap(decryptedPassword); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SHA1PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | try |
| | | { |
| | | storedPWDigestBytes = |
| | | ByteString.wrap(Base64.decode(storedPassword.toString())); |
| | | ByteString.wrap(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SaltedMD5PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | int saltLength = 0; |
| | | try |
| | | { |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()); |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()).toByteArray(); |
| | | |
| | | saltLength = decodedBytes.length - MD5_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | byte[] digestBytes; |
| | | try |
| | | { |
| | | saltBytes = Base64.decode(authInfo); |
| | | digestBytes = Base64.decode(authValue); |
| | | saltBytes = Base64.decode(authInfo).toByteArray(); |
| | | digestBytes = Base64.decode(authValue).toByteArray(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SaltedSHA1PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | int saltLength = 0; |
| | | try |
| | | { |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()); |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()).toByteArray(); |
| | | |
| | | saltLength = decodedBytes.length - SHA1_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | byte[] digestBytes; |
| | | try |
| | | { |
| | | saltBytes = Base64.decode(authInfo); |
| | | digestBytes = Base64.decode(authValue); |
| | | saltBytes = Base64.decode(authInfo).toByteArray(); |
| | | digestBytes = Base64.decode(authValue).toByteArray(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | Arrays.fill(passwordPlusSalt, (byte) 0); |
| | | |
| | | return "{" + STORAGE_SCHEME_NAME_SALTED_SHA_1 + "}" + |
| | | Base64.encode(digestPlusSalt); |
| | | Base64.encode(digestPlusSalt); |
| | | } |
| | | } |
| | |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SaltedSHA256PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | |
| | | try |
| | | { |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()); |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()).toByteArray(); |
| | | |
| | | saltLength = decodedBytes.length - SHA256_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | byte[] digestBytes; |
| | | try |
| | | { |
| | | saltBytes = Base64.decode(authInfo); |
| | | digestBytes = Base64.decode(authValue); |
| | | saltBytes = Base64.decode(authInfo).toByteArray(); |
| | | digestBytes = Base64.decode(authValue).toByteArray(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SaltedSHA384PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | |
| | | try |
| | | { |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()); |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()).toByteArray(); |
| | | |
| | | saltLength = decodedBytes.length - SHA384_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | byte[] digestBytes; |
| | | try |
| | | { |
| | | saltBytes = Base64.decode(authInfo); |
| | | digestBytes = Base64.decode(authValue); |
| | | saltBytes = Base64.decode(authInfo).toByteArray(); |
| | | digestBytes = Base64.decode(authValue).toByteArray(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.SaltedSHA512PasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | |
| | | |
| | | try |
| | | { |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()); |
| | | byte[] decodedBytes = Base64.decode(storedPassword.toString()).toByteArray(); |
| | | |
| | | saltLength = decodedBytes.length - SHA512_LENGTH; |
| | | if (saltLength <= 0) |
| | |
| | | byte[] digestBytes; |
| | | try |
| | | { |
| | | saltBytes = Base64.decode(authInfo); |
| | | digestBytes = Base64.decode(authValue); |
| | | saltBytes = Base64.decode(authInfo).toByteArray(); |
| | | digestBytes = Base64.decode(authValue).toByteArray(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | Arrays.fill(passwordPlusSalt, (byte) 0); |
| | | |
| | | return "{" + STORAGE_SCHEME_NAME_SALTED_SHA_512 + "}" + |
| | | Base64.encode(digestPlusSalt); |
| | | Base64.encode(digestPlusSalt); |
| | | } |
| | | } |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.server.config.server.TripleDESPasswordStorageSchemeCfg; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | ByteString decryptedPassword = |
| | | ByteString.wrap(cryptoManager.decrypt( |
| | | Base64.decode(storedPassword.toString()))); |
| | | return plaintextPassword.equals(decryptedPassword); |
| | | return plaintextPassword.equals(ByteString.wrap( |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()))); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | try |
| | | { |
| | | byte[] decryptedPassword = |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString())); |
| | | cryptoManager.decrypt(Base64.decode(storedPassword.toString()).toByteArray()); |
| | | return ByteString.wrap(decryptedPassword); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP search result entry |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | // See OPENDJ-2792: the definition of the ds-cfg-csv-delimiter-char attribute type |
| | | // had a space accidentally added after the closing parenthesis. |
| | | // This was unfortunately interpreted as base64 |
| | | definition = ByteString.wrap(Base64.decode(definition.substring(2).trim())).toString(); |
| | | definition = ByteString.wrap(Base64.decode(definition.substring(2).trim()).toByteArray()).toString(); |
| | | } |
| | | else if (definition.startsWith(":")) |
| | | { |
| | |
| | | */ |
| | | public static int serviceState() |
| | | { |
| | | return serviceState(NullOutputStream.printStream(), NullOutputStream.printStream()); |
| | | return serviceState(NullOutputStream.nullPrintStream(), NullOutputStream.nullPrintStream()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | |
| | | |
| | | if (quietMode.isPresent()) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | out = NullOutputStream.nullPrintStream(); |
| | | } |
| | | |
| | | if (checkStoppability.isPresent()) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.util.Base64; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | |
| | | /** |
| | | * This class defines a data structure for holding information about a |
| | |
| | | } |
| | | else if (name.equals(PROPERTY_UNSIGNED_HASH)) |
| | | { |
| | | unsignedHash = Base64.decode(value); |
| | | unsignedHash = Base64.decode(value).toByteArray(); |
| | | } |
| | | else if (name.equals(PROPERTY_SIGNED_HASH)) |
| | | { |
| | | signedHash = Base64.decode(value); |
| | | signedHash = Base64.decode(value).toByteArray(); |
| | | } |
| | | else if (name.equals(PROPERTY_DEPENDENCY)) |
| | | { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | * |
| | | * @return A print stream using this null output stream. |
| | | */ |
| | | public static PrintStream printStream() |
| | | public static PrintStream nullPrintStream() |
| | | { |
| | | return printStream; |
| | | } |
| | |
| | | |
| | | /** |
| | | * Returns s wrapped into a {@link PrintStream} if is not null, |
| | | * {@link NullOutputStream#printStream()} otherwise. |
| | | * {@link NullOutputStream#nullPrintStream()} otherwise. |
| | | * |
| | | * @param s |
| | | * the OutputStream to wrap into a {@link PrintStream}. Can be null. |
| | | * @return a PrintStream wrapping s if not null, |
| | | * {@link NullOutputStream#printStream()} otherwise. |
| | | * {@link NullOutputStream#nullPrintStream()} otherwise. |
| | | */ |
| | | public static PrintStream wrapOrNullStream(OutputStream s) |
| | | { |
| | |
| | | { |
| | | return new PrintStream(s); |
| | | } |
| | | return NullOutputStream.printStream(); |
| | | return NullOutputStream.nullPrintStream(); |
| | | } |
| | | |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | { |
| | | try |
| | | { |
| | | return new String(Base64.decode(encodedStr), "UTF-8"); |
| | | return new String(Base64.decode(encodedStr).toByteArray(), "UTF-8"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | value = ByteString.wrap(Base64.decode(line.substring(pos))); |
| | | value = ByteString.wrap(Base64.decode(line.substring(pos)).toByteArray()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | import static org.opends.server.loggers.TextAccessLogPublisher.getStartupTextAccessPublisher; |
| | | import static org.opends.server.loggers.TextErrorLogPublisher.getToolStartupTextErrorPublisher; |
| | | import static org.opends.server.loggers.TextHTTPAccessLogPublisher.getStartupTextHTTPAccessPublisher; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_RUNNING_UNIT_TESTS; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | import java.util.logging.LogManager; |
| | | import java.util.logging.Logger; |
| | | |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.dsconfig.DSConfig; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.LDAPReader; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | "-p", String.valueOf(ports.serverLdapPort), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-a", |
| | | "-f", path |
| | | }; |
| | | String[] adminArgs = |
| | |
| | | "-Z", "-X", |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-a", |
| | | "-f", path |
| | | }; |
| | | |
| | | if (useAdminPort) { |
| | | return LDAPModify.mainModify(adminArgs, false, null, null); |
| | | return LDAPModify.run(nullPrintStream(), nullPrintStream(), adminArgs); |
| | | } |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | return LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | } |
| | | |
| | | /** |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | public static int runLdapSearchTrustCertificateForSession(final String[] args) |
| | | { |
| | | return runLdapSearchTrustCertificateForSession(nullPrintStream(), System.err, args); |
| | | } |
| | | |
| | | public static int runLdapSearchTrustCertificateForSession(final PrintStream out, |
| | | final PrintStream err, |
| | | final String[] args) |
| | | { |
| | | final InputStream stdin = System.in; |
| | | try |
| | | { |
| | | // Since hostnames are different between the client.truststore (CN=OpenDJ Test Certificate, O=OpenDJ.org) and the |
| | | // one given in parameter (127.0.0.1), ldapsearch tool prompt user to know what to do (either untrust the server |
| | | // certificate, trust it for the session only or trust it permanently). |
| | | // Default option is session trust, we just hit enter in stdin to have a non blocking unit test. |
| | | System.setIn(new ByteArrayInputStream(System.lineSeparator().getBytes())); |
| | | return LDAPSearch.run(nullPrintStream(), System.err, args); |
| | | } |
| | | finally |
| | | { |
| | | System.setIn(stdin); |
| | | } |
| | | } |
| | | } |
| | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Set; |
| | |
| | | import org.opends.server.extensions.TestPasswordValidator; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.ModifyResponseProtocolOp; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), |
| | | 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOfUtf8("newPassword")); |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | int returnCode = LDAPPasswordModify.mainPasswordModify(args, false, null, |
| | | null); |
| | | int returnCode = LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertNotEquals(returnCode, 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | |
| | | "-w", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), |
| | | 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | Set<ByteString> currentPasswords = |
| | | TestPasswordValidator.getLastCurrentPasswords(); |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), |
| | | 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | Set<ByteString> currentPasswords = |
| | | TestPasswordValidator.getLastCurrentPasswords(); |
| | |
| | | "-w", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), |
| | | 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | Set<ByteString> currentPasswords = |
| | | TestPasswordValidator.getLastCurrentPasswords(); |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), |
| | | 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | Set<ByteString> currentPasswords = |
| | | TestPasswordValidator.getLastCurrentPasswords(); |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.PrintStream; |
| | | import java.io.StringReader; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | |
| | | argList.add("-J"); |
| | | argList.add(pwdPolicyControl); |
| | | } |
| | | |
| | | String[] args = new String[argList.size()]; |
| | | oStream.reset(); |
| | | int ret = LDAPPasswordModify.mainPasswordModify(argList.toArray(args), |
| | | false, oStream, oStream); |
| | | Assert.assertEquals(ret, expectedRc, "Returned error: " + oStream); |
| | | return oStream.toString(); |
| | | try (final PrintStream printStream = new PrintStream(oStream)) { |
| | | int ret = LDAPPasswordModify.run(printStream, printStream, argList.toArray(args)); |
| | | final String output = oStream.toString(); |
| | | Assert.assertEquals(ret, expectedRc, "ldappasswordmodify output: " + output); |
| | | return output; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | argList.add("-f"); |
| | | argList.add(tempFile.getAbsolutePath()); |
| | | String[] args = new String[argList.size()]; |
| | | |
| | | oStream.reset(); |
| | | int retVal =LDAPModify.mainModify(argList.toArray(args), false, oStream, oStream); |
| | | Assert.assertEquals(retVal, 0, "Returned error: " + oStream); |
| | | return oStream.toString(); |
| | | return runLdapModify(argList, 0); |
| | | } |
| | | |
| | | protected String LDAPSearchCtrl(String bindDn, String bindPassword, |
| | |
| | | argList.add(bindDn); |
| | | argList.add("-w"); |
| | | argList.add(bindPassword); |
| | | argList.add("-T"); |
| | | argList.add("-t"); |
| | | argList.add("0"); |
| | | if(proxyDN != null) { |
| | | argList.add("-Y"); |
| | | argList.add("dn:" + proxyDN); |
| | |
| | | argList.add("sub"); |
| | | argList.add(filter); |
| | | Collections.addAll(argList, attr.split("\\s+")); |
| | | String[] args = new String[argList.size()]; |
| | | oStream.reset(); |
| | | int retVal = |
| | | LDAPSearch.mainSearch(argList.toArray(args), false, oStream, oStream); |
| | | Assert.assertEquals(retVal, 0, "Returned error: " + oStream); |
| | | return oStream.toString(); |
| | | return runLdapSearch(argList); |
| | | } |
| | | |
| | | protected String |
| | |
| | | argList.add(bindDn); |
| | | argList.add("-w"); |
| | | argList.add(bindPassword); |
| | | argList.add("-T"); |
| | | argList.add("-t"); |
| | | argList.add("0"); |
| | | if(proxyDN != null) { |
| | | argList.add("-Y"); |
| | | argList.add("dn:" + proxyDN); |
| | |
| | | if(attr != null) { |
| | | Collections.addAll(argList, attr.split("\\s+")); |
| | | } |
| | | String[] args = new String[argList.size()]; |
| | | oStream.reset(); |
| | | int retVal = LDAPSearch.mainSearch(argList.toArray(args), false, oStream, oStream); |
| | | Assert.assertEquals(retVal, expectedRc, "Returned error: " + oStream); |
| | | return oStream.toString(); |
| | | return runLdapSearch(argList); |
| | | } |
| | | |
| | | protected void LDIFAdd(String ldif, String bindDn, String bindPassword, |
| | | String controlStr, int expectedRc) throws Exception |
| | | { |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, true, expectedRc, false); |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, expectedRc, false); |
| | | } |
| | | |
| | | protected void LDIFModify(String ldif, String bindDn, String bindPassword, |
| | | String controlStr, int expectedRc) throws Exception |
| | | { |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, false, expectedRc, false); |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, expectedRc, false); |
| | | } |
| | | |
| | | protected void LDIFModify(String ldif, String bindDn, String bindPassword) |
| | | throws Exception { |
| | | _LDIFModify(ldif, bindDn, bindPassword, null, false, -1, false); |
| | | _LDIFModify(ldif, bindDn, bindPassword, null, -1, false); |
| | | } |
| | | |
| | | protected void LDIFAdminModify (String ldif, String bindDn, |
| | | String bindPassword) |
| | | throws Exception { |
| | | _LDIFModify(ldif, bindDn, bindPassword, null, false, -1, true); |
| | | _LDIFModify(ldif, bindDn, bindPassword, null, -1, true); |
| | | } |
| | | |
| | | protected void LDIFModify(String ldif, String bindDn, String bindPassword, |
| | | String ctrlString) |
| | | throws Exception { |
| | | _LDIFModify(ldif, bindDn, bindPassword, ctrlString, false, -1, false); |
| | | _LDIFModify(ldif, bindDn, bindPassword, ctrlString, -1, false); |
| | | } |
| | | |
| | | protected void LDIFDelete(String dn, String bindDn, String bindPassword, |
| | |
| | | private void ldapDelete(String[] args, int expectedRc) |
| | | { |
| | | oStream.reset(); |
| | | int retVal = LDAPDelete.mainDelete(args, false, oStream, oStream); |
| | | Assert.assertEquals(retVal, expectedRc, "Returned error: " + oStream); |
| | | try (final PrintStream printStream = new PrintStream(oStream)) |
| | | { |
| | | final int retVal = LDAPDelete.run(printStream, printStream, args); |
| | | Assert.assertEquals(retVal, expectedRc, "ldapdelete output: " + oStream.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void _LDIFModify(String ldif, String bindDn, String bindPassword, |
| | | String controlStr, boolean add, int expectedRc, boolean useAdminPort) |
| | | String controlStr, int expectedRc, boolean useAdminPort) |
| | | throws Exception |
| | | { |
| | | File tempFile = getTemporaryLdifFile(); |
| | |
| | | argList.add("-J"); |
| | | argList.add(controlStr); |
| | | } |
| | | if(add) { |
| | | argList.add("-a"); |
| | | } |
| | | argList.add("-f"); |
| | | argList.add(tempFile.getAbsolutePath()); |
| | | String[] args = new String[argList.size()]; |
| | | ldapModify(argList.toArray(args), expectedRc); |
| | | runLdapModify(argList, expectedRc); |
| | | } |
| | | |
| | | protected void JNDIModify(Hashtable<?, ?> env, String name, String attr, |
| | |
| | | } |
| | | argList.add("-f"); |
| | | argList.add(tempFile.getAbsolutePath()); |
| | | String[] args = new String[argList.size()]; |
| | | ldapModify(argList.toArray(args), expectedRc); |
| | | } |
| | | |
| | | private void ldapModify(String[] args, int expectedRc) |
| | | { |
| | | oStream.reset(); |
| | | int retVal =LDAPModify.mainModify(args, false, oStream, oStream); |
| | | if (expectedRc != -1) |
| | | { |
| | | Assert.assertEquals(retVal, expectedRc, "Returned error: " + oStream); |
| | | } |
| | | runLdapModify(argList, expectedRc); |
| | | } |
| | | |
| | | protected void deleteAttrFromEntry(String dn, String attr) throws Exception { |
| | |
| | | return attrMap; |
| | | } |
| | | |
| | | private String runLdapModify(final List<String> argList, final int expectedReturnCode) |
| | | { |
| | | try (final PrintStream printStream = new PrintStream(oStream)) |
| | | { |
| | | final int retVal = LDAPModify.run(printStream, printStream, argList.toArray(new String[argList.size()])); |
| | | final String output = oStream.toString(); |
| | | if (expectedReturnCode != -1) |
| | | { |
| | | Assert.assertEquals(retVal, expectedReturnCode, "ldapmodify output: " + output); |
| | | } |
| | | return output; |
| | | } |
| | | } |
| | | |
| | | private String runLdapSearch(final List<String> argList) |
| | | { |
| | | try (final PrintStream printStream = new PrintStream(oStream)) |
| | | { |
| | | final int retVal = LDAPSearch.run(printStream, printStream, argList.toArray(new String[argList.size()])); |
| | | final String output = oStream.toString(); |
| | | Assert.assertEquals(retVal, 0, "ldapsearch output: " + output); |
| | | return output; |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.StringReader; |
| | | import java.io.PrintStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | import java.util.Set; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import com.forgerock.opendj.ldap.tools.LDAPCompare; |
| | | import com.forgerock.opendj.ldap.tools.LDIFDiff; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.LDAPCompare; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.tools.LDIFDiff; |
| | | import org.opends.server.tools.LDIFModify; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | |
| | | "-p", getServerLdapPort(), |
| | | "-D", _bindDn, |
| | | "-w", _bindPw, |
| | | "--useCompareResultCode", |
| | | attrAssertion, |
| | | _searchBaseDn}; |
| | | } |
| | |
| | | searchFilter, searchScope, expectedResultsLdif, _initialDitLdif, equivalentAci)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @return the LDIF result of applying changesLdif to changesLdif |
| | | */ |
| | | private String applyChangesToLdif(String baseLdif, String changesLdif) throws Exception { |
| | | LDIFReader baseReader = new LDIFReader(new LDIFImportConfig(new StringReader(baseLdif))); |
| | | LDIFReader changesReader = new LDIFReader(new LDIFImportConfig(new StringReader(changesLdif))); |
| | | |
| | | ByteArrayOutputStream updatedEntriesStream = new ByteArrayOutputStream(); |
| | | LDIFWriter ldifWriter = new LDIFWriter(new LDIFExportConfig(updatedEntriesStream)); |
| | | |
| | | List<LocalizableMessage> errors = new ArrayList<>(); |
| | | LDIFModify.modifyLDIF(baseReader, changesReader, ldifWriter, errors); |
| | | Assert.assertTrue(errors.isEmpty(), "Unexpected errors applying LDIF changes: " + errors); |
| | | ldifWriter.flush(); |
| | | |
| | | return updatedEntriesStream.toString(); |
| | | } |
| | | } |
| | | |
| | | @DataProvider |
| | |
| | | "-p", getServerLdapPort(), |
| | | "-D", bindDn, |
| | | "-w", bindPassword, |
| | | "-a", |
| | | "-f", tempFile.getAbsolutePath() |
| | | }; |
| | | |
| | |
| | | |
| | | private void ldapModify(String[] args, boolean expectSuccess) throws Exception { |
| | | clearOutputStream(); |
| | | int retVal = LDAPModify.mainModify(args, false, getOutputStream(), getOutputStream()); |
| | | int retVal = LDAPModify.run(getOutputPrintStream(), getOutputPrintStream(), args); |
| | | assertEquals(retVal == 0, expectSuccess, "Return value = " + retVal); |
| | | } |
| | | |
| | | private String ldapSearch(String[] args) throws Exception { |
| | | clearOutputStream(); |
| | | int retVal = LDAPSearch.mainSearch(args, false, getOutputStream(), getOutputStream()); |
| | | int retVal = LDAPSearch.run(getOutputPrintStream(), getOutputPrintStream(), args); |
| | | Assert.assertEquals(retVal, 0, "Non-zero return code because, error: " + getOutputStreamContents()); |
| | | return getOutputStreamContents(); |
| | | } |
| | | |
| | | private String ldapCompare(String[] args, int expectedRc) throws Exception { |
| | | clearOutputStream(); |
| | | int retVal = LDAPCompare.mainCompare(args, false, getOutputStream(), getOutputStream()); |
| | | int retVal = LDAPCompare.run(getOutputPrintStream(), getOutputPrintStream(), args); |
| | | Assert.assertEquals(retVal, expectedRc, "Non-zero return code because, error: " + getOutputStreamContents()); |
| | | return getOutputStreamContents(); |
| | | } |
| | |
| | | |
| | | String[] args = |
| | | { |
| | | "--sourceLDIF", actualLdifFile.getAbsolutePath(), |
| | | "--targetLDIF", expectedLdifFile.getAbsolutePath(), |
| | | "--outputLDIF", diffLdifFile.getAbsolutePath() |
| | | "--outputLDIF", diffLdifFile.getAbsolutePath(), |
| | | actualLdifFile.getAbsolutePath(), |
| | | expectedLdifFile.getAbsolutePath() |
| | | }; |
| | | |
| | | int retVal = LDIFDiff.mainDiff(args, true, System.out, System.err); |
| | | int retVal = LDIFDiff.run(System.out, System.err, args); |
| | | assertEquals(retVal, 0, "LDIFDiff failed"); |
| | | |
| | | if (diffLdifFile.exists()) { |
| | |
| | | return _cmdOutput; |
| | | } |
| | | |
| | | private static PrintStream getOutputPrintStream() { |
| | | return new PrintStream(getOutputStream()); |
| | | } |
| | | |
| | | private static String makeUserLdif(String dn, String givenName, String sn, String password) { |
| | | String cn = givenName + " " + sn; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.server.authorization.dseecompat; |
| | |
| | | { |
| | | break; |
| | | } |
| | | if(s.startsWith("SearchReference")) { |
| | | if(s.startsWith("SearchResultReference")) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | String noOpCtrlStr=OID_LDAP_NOOP_OPENLDAP_ASSIGNED + ":true"; |
| | | //This pwd change should return no-op since the no-op control is |
| | | //specified and it is allowed for authorization dn. |
| | | pwdModify(level3User, PWD, newPWD, noOpCtrlStr, null, |
| | | LDAPResultCode.NO_OPERATION); |
| | | pwdModify(level3User, PWD, newPWD, noOpCtrlStr, null, LDAPResultCode.SUCCESS); |
| | | //This pwd change should fail even though the no-op is specified, since |
| | | //since the no-op control is not allowed for this authorization dn. |
| | | pwdModify(superUser, PWD, newPWD, noOpCtrlStr, null, |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tasks.LdifFileWriter; |
| | | import org.opends.server.tasks.TasksTestCase; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | "-w", "password", |
| | | "-f", subtreeDeletePath |
| | | }; |
| | | resultCode = LDAPModify.mainModify(args, false, System.out, System.err); |
| | | resultCode = LDAPModify.run(System.out, System.err, args); |
| | | assertEquals(resultCode, ResultCode.NOT_ALLOWED_ON_NONLEAF.intValue()); |
| | | |
| | | |
| | |
| | | "-J", "subtreeDelete", |
| | | "-f", subtreeDeletePath |
| | | }; |
| | | resultCode = LDAPModify.mainModify(args, false, System.out, System.err); |
| | | resultCode = LDAPModify.run(System.out, System.err, args); |
| | | assertEquals(resultCode, 0); |
| | | } |
| | | |
| | |
| | | "-J", "subtreeDelete", |
| | | "-f", path |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | assertFalse(DirectoryServer.entryExists(DN.valueOf("o=ldif"))); |
| | | assertFalse(DirectoryServer.entryExists( |
| | | DN.valueOf("uid=user.1,ou=People,o=ldif"))); |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.ExistingFileBehavior.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.schema.SchemaHandler; |
| | | import org.opends.server.schema.SchemaHandler.SchemaUpdater; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | |
| | | |
| | | private void runModify(String[] args, String ldifContent, ResultCode expectedRC) |
| | | { |
| | | runModify(args, ldifContent, null, expectedRC); |
| | | runModify(args, ldifContent, nullPrintStream(), expectedRC); |
| | | } |
| | | |
| | | private void runModify(String[] args, String ldifContent, PrintStream stderr, ResultCode expectedRC) |
| | |
| | | try |
| | | { |
| | | System.setIn(new ByteArrayInputStream(ldifContent.getBytes())); |
| | | return LDAPModify.mainModify(args, false, stdout, stderr); |
| | | return LDAPModify.run(stdout, stderr, args); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | "{ serialNumber 13233831500277100508, issuer rdnSequence:\""+ |
| | | "CN=Babs Jensen,OU=Product Development,L=Cupertione,C=US\" }"; |
| | | return new Object[][]{ |
| | | {"userCertificate", ByteString.wrap(Base64.decode(BASE64_CERT_VALUE)), |
| | | {"userCertificate", ByteString.wrap(Base64.decode(BASE64_CERT_VALUE).toByteArray()), |
| | | CERT_EXACT_ASSERTION}}; |
| | | } |
| | | |
| | |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPReader; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, |
| | | true, null, System.err),11); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 11); |
| | | //cancel the persisting persistent search. |
| | | search.cancel(new CancelRequest(true,LocalizableMessage.EMPTY)); |
| | | } |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.AddRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.AuthenticationType; |
| | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "ou=people,dc=example,dc=com" |
| | | }; |
| | | assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0); |
| | | assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN)); |
| | | } |
| | |
| | | "--noPropertiesFile", |
| | | "-f", path |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com"); |
| | | assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN)); |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), 0); |
| | | |
| | | args = new String[] |
| | | { |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | int rc = LDAPSearch.mainSearch(args, false, System.out, System.err); |
| | | int rc = LDAPSearch.run(System.out, System.err, args); |
| | | assertFalse(rc == 0); |
| | | assertFalse(rc == LDAPResultCode.INVALID_CREDENTIALS); |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), |
| | | LDAPResultCode.INVALID_CREDENTIALS); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), LDAPResultCode.INVALID_CREDENTIALS); |
| | | |
| | | args = new String[] |
| | | { |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPSearch.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | import org.opends.server.plugins.ShortCircuitPlugin; |
| | | import org.opends.server.protocols.ldap.DeleteRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = getArgs("o=test"); |
| | | assertEquals(LDAPDelete.mainDelete(args, false, null, null), 0); |
| | | assertEquals(LDAPDelete.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | String[] args = getArgs("o=test"); |
| | | assertFalse(LDAPDelete.mainDelete(args, false, null, null) == 0); |
| | | assertFalse(LDAPDelete.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.ENABLED); |
| | | } |
| | |
| | | backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | String[] args = getArgs("o=test"); |
| | | assertFalse(LDAPDelete.mainDelete(args, false, null, null) == 0); |
| | | assertFalse(LDAPDelete.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | backend.setWritabilityMode(WritabilityMode.ENABLED); |
| | | } |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.MemberList; |
| | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "ou=groups,dc=example,dc=com" |
| | | }; |
| | | assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0); |
| | | assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | InternalClientConnection conn1 = |
| | | new InternalClientConnection(userDN); |
| | |
| | | "--noPropertiesFile", |
| | | "-f", path |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | InternalClientConnection conn1 = |
| | | new InternalClientConnection(userDN); |
| | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.newSearchRequest; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.protocols.ldap.ModifyRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ModifyResponseProtocolOp; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.WritabilityMode; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | private String firstValue(List<Attribute> attrs) |
| | |
| | | "axuJ8LFNbZtsp1ldW3i84+F5+SYT+xI67ZcoAtwx/VFVI9s5I/Gkmu9f9nxjPpK7" + |
| | | "1AIUXiE3Qcck"; |
| | | |
| | | ByteString value = ByteString.wrap(Base64.decode(certificateValue)); |
| | | ByteString value = ByteString.wrap(Base64.decode(certificateValue).toByteArray()); |
| | | LDAPAttribute attr = new LDAPAttribute("usercertificate", value); |
| | | ModifyOperation modifyOperation = processModify("uid=test.user," + baseDN, new LDAPModification(ADD, attr)); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.extensions.InitializationUtils; |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", newPWsPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), |
| | | 0); |
| | | |
| | | |
| | |
| | | "-f", newPWsPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), |
| | | 0); |
| | | |
| | | |
| | |
| | | "-f", origPWPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | { |
| | | // Make sure that we cannot re-use the original password as a new |
| | | // password. |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | 0); |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == 0); |
| | | |
| | | |
| | | // Change the password three times. |
| | |
| | | "-f", newPWsPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | |
| | | |
| | | advanceTimeThread(); |
| | |
| | | "-f", origPWPath |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | 0); |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == 0); |
| | | |
| | | |
| | | // Change the password one more time and then verify that we can use the |
| | |
| | | "-f", newPWsPath2 |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | |
| | | |
| | | advanceTimeThread(); |
| | |
| | | "-f", firstPWPath |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | 0); |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == 0); |
| | | |
| | | |
| | | advanceTimeThread(); |
| | |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-history-count:2"); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", origPWPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | |
| | | { |
| | | // Make sure that we can no longer re-use the original password as a new |
| | | // password. |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | 0); |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == 0); |
| | | |
| | | |
| | | // Change the password three times. |
| | |
| | | "-f", newPWsPath |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | |
| | | |
| | | // Make sure that we still can't use the original password. |
| | |
| | | "-f", origPWPath |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | 0); |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == 0); |
| | | |
| | | |
| | | // Sleep for six seconds and then verify that we can use the original |
| | | // password again. |
| | | Thread.sleep(6000); |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == |
| | | 0); |
| | | } |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, System.out, System.err) == |
| | | assertFalse(LDAPModify.run(System.out, System.err, args) == |
| | | 0); |
| | | } |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.forgerock.opendj.ldap.tools.LDAPCompare; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPAuthenticationHandler; |
| | | import org.opends.server.tools.LDAPCompare; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.Control; |
| | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "dn: o=rejectTestCase,o=test", "objectclass: top", |
| | | "objectclass: organization", "o: rejectTestCase", |
| | | "description: Reject Test Case"); |
| | | return LDAPModify.mainModify(addArgs(authenticate, filePath), false, null, null); |
| | | return LDAPModify.run(nullPrintStream(), nullPrintStream(), modifyArgs(authenticate, filePath)); |
| | | } |
| | | |
| | | private String[] modifyArgs(boolean authenticate, String filePath) |
| | | { |
| | | return args(authenticate, false, filePath); |
| | | return args(authenticate, filePath); |
| | | } |
| | | |
| | | private String[] addArgs(boolean authenticate, String filePath) |
| | | { |
| | | return args(authenticate, true, filePath); |
| | | } |
| | | |
| | | private String[] args(boolean authenticate, boolean add, String filePath) |
| | | private String[] args(boolean authenticate, String filePath) |
| | | { |
| | | Args args = new Args(); |
| | | args.add("--noPropertiesFile"); |
| | |
| | | args.add("-D", "cn=directory manager"); |
| | | args.add("-w", "password"); |
| | | } |
| | | if (add) |
| | | { |
| | | args.add("-a"); |
| | | } |
| | | args.add("-f", filePath); |
| | | return args.toArray(); |
| | | } |
| | |
| | | String path = TestCaseUtils.createTempFile("dn: o=rejectTestCase,o=test", |
| | | "changetype: modify", "replace: description", |
| | | "description: New Description"); |
| | | return LDAPModify.mainModify(modifyArgs(authenticate, path), false, null, null); |
| | | return LDAPModify.run(nullPrintStream(), nullPrintStream(), modifyArgs(authenticate, path)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private int performCompareOperation(boolean authentication) throws Exception |
| | | { |
| | | return LDAPCompare.mainCompare(compareArgs(authentication), false, null, null); |
| | | return LDAPCompare.run(nullPrintStream(), nullPrintStream(), compareArgs(authentication)); |
| | | } |
| | | |
| | | private String[] compareArgs(boolean authenticate) |
| | |
| | | String path = TestCaseUtils |
| | | .createTempFile("dn: o=rejectTestCase,o=Test", "changetype: modrdn", |
| | | "newrdn: o=mod_rejectTestCase", "deleteoldrdn: 0"); |
| | | return LDAPModify.mainModify(modRdnArgs(authentication, path), false, null, null); |
| | | return LDAPModify.run(nullPrintStream(), nullPrintStream(), modRdnArgs(authentication, path)); |
| | | } |
| | | |
| | | private String[] modRdnArgs(boolean authenticate, String path) |
| | |
| | | */ |
| | | private int performDeleteOperation(boolean authentication) throws Exception |
| | | { |
| | | return LDAPDelete.mainDelete(deleteArgs(authentication), false, null, null); |
| | | return LDAPDelete.run(nullPrintStream(), nullPrintStream(), deleteArgs(authentication)); |
| | | } |
| | | |
| | | private String[] deleteArgs(boolean authenticate) |
| | |
| | | args.add("-p", TestCaseUtils.getServerLdapPort()); |
| | | if (authenticate) |
| | | { |
| | | args.add("-V", "3"); |
| | | args.add("-D", "cn=Directory Manager"); |
| | | args.add("-w", "password"); |
| | | } |
| | |
| | | public void testAuthSearchDefCfg() |
| | | { |
| | | DirectoryServer.setRejectUnauthenticatedRequests(false); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs(Auth.SIMPLE), false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, searchArgs(Auth.SIMPLE)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testUnauthSearchDefCfg() |
| | | { |
| | | DirectoryServer.setRejectUnauthenticatedRequests(false); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs(Auth.ANONYMOUS), false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, searchArgs(Auth.ANONYMOUS)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testStartTLSUnauthDefCfg() throws Exception |
| | | { |
| | | DirectoryServer.setRejectUnauthenticatedRequests(false); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs(Auth.START_TLS), false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, searchArgs(Auth.START_TLS)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | DirectoryServer.setRejectUnauthenticatedRequests(true); |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(searchArgs(Auth.ANONYMOUS), false, null, null) == 0); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs(Auth.START_TLS), false, null, System.err), 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), searchArgs(Auth.ANONYMOUS)) == 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, searchArgs(Auth.START_TLS)), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | try |
| | | { |
| | | DirectoryServer.setRejectUnauthenticatedRequests(true); |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs(Auth.START_TLS), false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, searchArgs(Auth.START_TLS)), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | import org.opends.server.protocols.ldap.SearchRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Control; |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | |
| | | assertEquals(err,0); |
| | | |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err, 0); |
| | | } |
| | | } |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPDelete; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | "--noPropertiesFile", |
| | | SUFFIX |
| | | }; |
| | | assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0); |
| | | assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | assertTrue(DirectoryServer.getSubentryManager().getCollectiveSubentries( |
| | | DN.valueOf("uid=rogasawara," + BASE)).isEmpty()); |
| | |
| | | "--noPropertiesFile", |
| | | "-f", newPath |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(newArgs, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, newArgs), 0); |
| | | |
| | | assertNotNull(DirectoryServer.getEntry(DN.valueOf( |
| | | "uid=rogasawara," + NEWBASE + "," + SUFFIX))); |
| | |
| | | "--noPropertiesFile", |
| | | "-f", oldPath |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(oldArgs, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, oldArgs), 0); |
| | | |
| | | assertNotNull(DirectoryServer.getEntry(DN.valueOf( |
| | | "uid=rogasawara," + OLDBASE + "," + SUFFIX))); |
| | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.protocols.ldap.ModifyDNRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ModifyDNResponseProtocolOp; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.CancelRequest; |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.BindOperationBasis; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.Control; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-o", "mech=ANONYMOUS", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | |
| | | "--noPropertiesFile", |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-o", "mech=ANONYMOUS", |
| | | "-o", "trace=LDAP Trace String", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(e.getName()); |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.TestCaseUtils.runLdapSearchTrustCertificateForSession; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | |
| | | mods.clear(); |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | |
| | | mods.clear(); |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | |
| | | mods.clear(); |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.runLdapSearchTrustCertificateForSession; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.forgerock.opendj.server.config.meta.FingerprintCertificateMapperCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "cn=config", |
| | | "-s", "sub", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(DN.valueOf("cn=Directory Manager"), "newPassword"); |
| | | |
| | |
| | | "-c", "newPassword", |
| | | "-n", "password" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-c", "password", |
| | | "-n", "newPassword", |
| | | "-A" |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(DN.valueOf("cn=Directory Manager"), "newPassword"); |
| | | |
| | |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "newPassword", |
| | | "-c", "newPassword", |
| | | "-n", "password", |
| | | "-A" |
| | | "-n", "password" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(DN.valueOf("cn=Directory Manager"), "newPassword"); |
| | | |
| | |
| | | "-c", "newPassword", |
| | | "-n", "password" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-w", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-D", "uid=test.user,o=test", |
| | | "-w", "password" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-a", "dn:uid=test.user,o=test", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-a", "u:test.user", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-a", "uid=test.user,o=test", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-a", "test.user", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-c", "password", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-a", "dn:uid=test.user,o=test", |
| | | "-n", "newPassword" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | verifyPasswordPerformingInternalBind(userEntry.getName(), "newPassword"); |
| | | } |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 32); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 32); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 49); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 49); |
| | | } |
| | | |
| | | |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | | } |
| | |
| | | "-n", "{SSHA}Fv4b7f4AnRMUiGqBi9QA1xJrTtRTqS3WpRi81g==" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | // don't restore password policy as this is already the default. |
| | | } |
| | | |
| | |
| | | "-n", "{SSHA}Fv4b7f4AnRMUiGqBi9QA1xJrTtRTqS3WpRi81g==" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | |
| | | |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "true"); |
| | | } |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 53); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 53); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "true"); |
| | | } |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } finally { |
| | | // Reset to default configuration |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 13); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 13); |
| | | } finally { |
| | | // Reset to default configuration |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 13); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 13); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | | } |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 13); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 13); |
| | | } finally { |
| | | // Reset to default configuration |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "0 seconds"); |
| | | } |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 53); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 53); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "0 seconds"); |
| | | } |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr1, "0 seconds"); |
| | | applyPwdPolicyMods(dnStr, attr2, "false"); |
| | |
| | | "-n", "newPassword" |
| | | }; |
| | | |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | finally { |
| | | applyPwdPolicyMods(dnStr, attr1, "0 seconds"); |
| | |
| | | "-w", "password" |
| | | }; |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "cn=Random Password Generator,cn=Password Generators,cn=config"); |
| | | } |
| | |
| | | "-c", "password" |
| | | }; |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | finally { |
| | | applyPwdPolicyMods(dnStr, attr, "cn=Random Password Generator,cn=Password Generators,cn=config"); |
| | |
| | | "-n", "short" |
| | | }; |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | finally { |
| | | applyPwdPolicyMods(dnStr, attr); |
| | |
| | | "-n", "short" |
| | | }; |
| | | try { |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, null)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args)); |
| | | } |
| | | finally { |
| | | applyPwdPolicyMods(dnStr, attr); |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | | } |
| | |
| | | }; |
| | | |
| | | try { |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), System.err, args), 0); |
| | | } finally { |
| | | applyPwdPolicyMods(dnStr, attr, "false"); |
| | | } |
| | |
| | | "-n", "newpassword" |
| | | }; |
| | | |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | |
| | | "-n", "newpassword" |
| | | }; |
| | | |
| | | assertFalse(0 == LDAPPasswordModify.mainPasswordModify(args, false, null, System.err)); |
| | | assertFalse(0 == LDAPPasswordModify.run(nullPrintStream(), System.err, args)); |
| | | |
| | | userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | |
| | | "-c", "password" |
| | | }; |
| | | |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | SchemaConstants.NO_ATTRIBUTES |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | } |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.runLdapSearchTrustCertificateForSession; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the use of the StartTLS extended operation to communicate with the |
| | | * server in conjunction with SASL EXTERNAL authentication and using blind |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-X", |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.runLdapSearchTrustCertificateForSession; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.forgerock.opendj.server.config.meta.SubjectAttributeToUserAttributeCertificateMapperCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client-emailAddress.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client-emailAddress.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, System.err) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", getKeyStorePath("client.keystore"), |
| | | "-W", "password", |
| | | "-P", getTrustStorePath(), |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N","client-cert", |
| | | "-b", "cn=config", |
| | | "-s", "sub", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.runLdapSearchTrustCertificateForSession; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(runLdapSearchTrustCertificateForSession(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-K", keyStorePath, |
| | | "-W", "password", |
| | | "-P", trustStorePath, |
| | | "-r", |
| | | "-o", "mech=EXTERNAL", |
| | | "-N", "client-cert", |
| | | "-b", "cn=config", |
| | | "-s", "sub", |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runLdapSearchTrustCertificateForSession(args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Modification; |
| | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | |
| | | for (int i=0; i < 7; i++) |
| | | { |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | String.valueOf(TestCaseUtils.getServerLdapPort()), "-D", |
| | | "cn=Directory Manager", "-w", "password", "-f", path1 }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args1, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args1) == 0); |
| | | |
| | | String path2 = |
| | | TestCaseUtils.createTempFile("dn: " + ruleDN, |
| | |
| | | "-X", "-D", "cn=Directory Manager", "-w", "password", |
| | | "-f", path2 }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args2, false, null, null), 0); |
| | | assertEquals(LDAPModify.mainModify(args1, false, null, null), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args2), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args1), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | String.valueOf(TestCaseUtils.getServerLdapPort()), "-D", |
| | | userDN, "-w", "password", "-f", path1 }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args1, false, null, null) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), nullPrintStream(), args1) == 0); |
| | | |
| | | String path2 = |
| | | TestCaseUtils.createTempFile("dn: " + ruleDN, |
| | |
| | | "-X", "-D", "cn=Directory Manager", "-w", "password", |
| | | "-f", path2 }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args2, false, null, null), 0); |
| | | assertEquals(LDAPModify.mainModify(args1, false, null, null), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args2), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args1), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), ResultCode.CONSTRAINT_VIOLATION.intValue()); |
| | | } |
| | | finally |
| | | { |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | 0); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), 0); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err,0); |
| | | |
| | | //ADD with ;binary option. |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath |
| | | }; |
| | | err = LDAPModify.mainModify(args, false, null,null); |
| | | err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err,0); |
| | | } |
| | | |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath, |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertThat(err).isNotEqualTo(0); |
| | | } |
| | | |
| | |
| | | .addAttribute("sn", "sn#1") |
| | | .addAttribute("sn;x-foo", "sn#2") |
| | | .addAttribute("sn;lang-fr", "sn#3") |
| | | .addAttribute("userCertificate;binary", ByteString.wrap(Base64.decode(CERT))); |
| | | .addAttribute("userCertificate;binary", ByteString.wrap(Base64.decode(CERT).toByteArray())); |
| | | LDAPMessage message = conn.add(addRequest); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertEquals(addResponse.getResultCode(),0); |
| | |
| | | "-b", "o=test", |
| | | "(uid=user.1)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | exportBackend(); |
| | | assertTrue(ldif.exists()); |
| | | assertTrue(containsBinary()); |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath, |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err,0); |
| | | |
| | | filePath = TestCaseUtils.createTempFile( |
| | |
| | | "-w","password", |
| | | "-f", filePath, |
| | | }; |
| | | err = LDAPModify.mainModify(args, false, null,null); |
| | | err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err,0); |
| | | } |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | |
| | | BufferedReader reader = |
| | | new BufferedReader(new StringReader(buffer.toString())); |
| | | String line = reader.readLine(); |
| | | assertEquals(line, "dn:: "+Base64.encode(dnNeedsBase64)); |
| | | assertEquals(line, "dn:: "+ Base64.encode(dnNeedsBase64)); |
| | | for (int i = 0; i < numAttributes; i++) |
| | | { |
| | | for (int j = 0; j < numValues; j++) |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileReader; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.LDAPConnectionFactory; |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | | import org.forgerock.opendj.ldap.requests.DeleteRequest; |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.forgerock.opendj.ldap.responses.Result; |
| | | import org.forgerock.util.promise.ResultHandler; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | public class ChangeNumberControlPluginTestCase extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| | | * The port of the replicationServer. |
| | | */ |
| | | private int replServerPort; |
| | | private static final String HOSTNAME = "127.0.0.1"; |
| | | |
| | | private static final Control CSN_CONTROL = new Control() |
| | | { |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return OID_CSN_CONTROL; |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getValue() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasValue() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isCritical() |
| | | { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | private static final ResultHandler<Result> ASSERTION_RESULT_HANDLER = new ResultHandler<Result>() |
| | | { |
| | | @Override |
| | | public void handleResult(final Result result) |
| | | { |
| | | assertTrue(result.containsControl(CSN_CONTROL.getOID())); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * The replicationServer that will be used in this test. |
| | |
| | | super.setUp(); |
| | | |
| | | baseDn = DN.valueOf(TEST_ROOT_DN_STRING); |
| | | |
| | | replServerPort = TestCaseUtils.findFreePort(); |
| | | final int replServerPort = TestCaseUtils.findFreePort(); |
| | | |
| | | // replication server |
| | | String replServerLdif = |
| | |
| | | configureReplication(replServerLdif, synchroServerLdif); |
| | | } |
| | | |
| | | @DataProvider(name = "operations") |
| | | public Object[][] createLdapRequests() { |
| | | return new Object[][] { |
| | | new Object[] { |
| | | "dn: cn=user1," + baseDn + "\n" |
| | | + "changetype: add" + "\n" |
| | | + "objectClass: person" + "\n" |
| | | + "cn: user1" + "\n" |
| | | + "sn: User Test 10"}, |
| | | new Object[] { |
| | | "dn: cn=user1," + baseDn + "\n" |
| | | + "changetype: modify" + "\n" |
| | | + "add: description" + "\n" |
| | | + "description: blah"}, |
| | | new Object[] { |
| | | "dn: cn=user1," + baseDn + "\n" |
| | | + "changetype: moddn" + "\n" |
| | | + "newrdn: cn=user111" + "\n" |
| | | + "deleteoldrdn: 1"}, |
| | | new Object[] { |
| | | "dn: cn=user111," + baseDn + "\n" |
| | | + "changetype: delete"} |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider="operations") |
| | | public void ChangeNumberControlTest(String request) throws Exception { |
| | | |
| | | String path = TestCaseUtils.createTempFile(request); |
| | | |
| | | String[] args = |
| | | @Test |
| | | public void changeNumberControlAddRequestTest() throws Exception { |
| | | try (final LDAPConnectionFactory factory = new LDAPConnectionFactory(HOSTNAME, getServerLdapPort()); |
| | | final Connection connection = factory.getConnection()) |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", OID_CSN_CONTROL + ":false", |
| | | "--noPropertiesFile", |
| | | "-f", path |
| | | }; |
| | | |
| | | String resultPath = TestCaseUtils.createTempFile(); |
| | | |
| | | FileOutputStream fos = new FileOutputStream(resultPath); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, fos, System.err), 0); |
| | | //fos.flush(); |
| | | fos.close(); |
| | | |
| | | assertTrue(isCsnLinePresent(resultPath)); |
| | | } |
| | | |
| | | private boolean isCsnLinePresent(String file) throws Exception { |
| | | FileReader fr = new FileReader(file); |
| | | try |
| | | { |
| | | BufferedReader br = new BufferedReader(fr); |
| | | String line = null; |
| | | boolean found = false; |
| | | while ((line = br.readLine()) != null) |
| | | { |
| | | if (line.contains(INFO_CHANGE_NUMBER_CONTROL_RESULT.get("%s", "%s") |
| | | .toString().split("%s")[1])) |
| | | { |
| | | found = true; |
| | | } |
| | | } |
| | | return found; |
| | | } |
| | | finally |
| | | { |
| | | StaticUtils.close(fr); |
| | | final AddRequest addRequest = Requests.newAddRequest("dn: cn=user1," + baseDn, |
| | | "changetype: add", |
| | | "objectClass: person", |
| | | "cn: user1", |
| | | "sn: User Test 10") |
| | | .addControl(CSN_CONTROL); |
| | | connection.addAsync(addRequest) |
| | | .thenOnResult(ASSERTION_RESULT_HANDLER); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void changeNumberControlDeleteRequestTest() throws Exception |
| | | { |
| | | try (final LDAPConnectionFactory factory = new LDAPConnectionFactory(HOSTNAME, getServerLdapPort()); |
| | | final Connection connection = factory.getConnection()) |
| | | { |
| | | final DeleteRequest deleteRequest = Requests.newDeleteRequest("cn=user111," + baseDn) |
| | | .addControl(CSN_CONTROL); |
| | | connection.deleteAsync(deleteRequest) |
| | | .thenOnResult(ASSERTION_RESULT_HANDLER); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void changeNumberControlModifyRequestTest() throws Exception |
| | | { |
| | | try (final LDAPConnectionFactory factory = new LDAPConnectionFactory(HOSTNAME, getServerLdapPort()); |
| | | final Connection connection = factory.getConnection()) |
| | | { |
| | | final ModifyRequest modifyRequest = Requests.newModifyRequest("dn: cn=user1," + baseDn, |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: blah") |
| | | .addControl(CSN_CONTROL); |
| | | connection.modifyAsync(modifyRequest).thenOnResult(ASSERTION_RESULT_HANDLER); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void changeNumberControlModifyDNRequestTest() throws Exception |
| | | { |
| | | try (final LDAPConnectionFactory factory = new LDAPConnectionFactory(HOSTNAME, getServerLdapPort()); |
| | | final Connection connection = factory.getConnection()) |
| | | { |
| | | final ModifyDNRequest modifyDNRequest = Requests.newModifyDNRequest("cn=user.1" + baseDn, "cn=user.111") |
| | | .addControl(CSN_CONTROL) |
| | | .setDeleteOldRDN(true); |
| | | connection.modifyDNAsync(modifyDNRequest) |
| | | .thenOnResult(ASSERTION_RESULT_HANDLER); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | + "cn: "+useri+"_cn"+"\n" |
| | | + "sn: "+useri+"_sn"+"\n" |
| | | + "uid: "+useri+"_uid"+"\n" |
| | | + "description:: "+ Base64.encode( |
| | | new String(bigAttributeValue).getBytes())+"\n" |
| | | + "description:: "+ Base64.encode(new String(bigAttributeValue).getBytes()) +"\n" |
| | | + "entryUUID: 21111111-1111-1111-1111-"+useri+ |
| | | filler.substring(0, 12-useri.length())+"\n" |
| | | + "\n"; |
| | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.opends.server.replication.protocol.LDAPUpdateMsg; |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | |
| | | private void ldapmodify(String[] args) |
| | | { |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-a", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, null), 53); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args), 53); |
| | | |
| | | // Test that we can't add an entry with the ds-sync-hist attribute |
| | | // without specifying the replication repair control. |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-a", |
| | | "-f", path1 |
| | | }; |
| | | |
| | | |
| | | assertEquals(LDAPModify.mainModify(args1, false, null, null), 53); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args1), 53); |
| | | |
| | | // Now Test specifying the replication repair control makes |
| | | // possible to add an entry with the entryuuid and ds-sync-hist attributes |
| | |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.3.6.1.4.1.26027.1.5.2", |
| | | "-a", |
| | | "-f", path2 |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args2, false, null, null), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), nullPrintStream(), args2), 0); |
| | | } |
| | | } |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.PrintStream; |
| | | import java.net.SocketException; |
| | | import java.util.Arrays; |
| | | import java.util.SortedSet; |
| | |
| | | import org.opends.server.replication.server.changelog.file.ECLEnabledDomainPredicate; |
| | | import org.opends.server.replication.service.DSRSShutdownSync; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | oStream.reset(); |
| | | eStream.reset(); |
| | | int retVal = |
| | | LDAPSearch.mainSearch(args3, false, oStream, eStream); |
| | | int retVal = LDAPSearch.run(new PrintStream(oStream), new PrintStream(eStream), args3); |
| | | String entries = oStream.toString(); |
| | | debugInfo("Entries:" + entries); |
| | | assertEquals(retVal, 0, "Returned error: " + eStream); |
| | |
| | | import org.opends.server.controls.VLVRequestControl; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** Integration tests for collation matching rules. */ |
| | |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D","cn=directory manager", |
| | | "-w","password", |
| | | "-a", |
| | | "-f", filePath, |
| | | }; |
| | | int err = LDAPModify.mainModify(args, false, null,null); |
| | | int err = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | assertEquals(err,0); |
| | | } |
| | | |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | LDAPResultCode.UNWILLING_TO_PERFORM); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), LDAPResultCode.UNWILLING_TO_PERFORM); |
| | | |
| | | |
| | | // Update the set of allowed tasks to include the dummy task. |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | LDAPResultCode.SUCCESS); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), LDAPResultCode.SUCCESS); |
| | | |
| | | waitTaskCompletedSuccessfully(DN.valueOf( |
| | | "ds-task-id=testAllowedTask 2,cn=Scheduled Tasks,cn=Tasks")); |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, System.out, System.err), |
| | | LDAPResultCode.UNWILLING_TO_PERFORM); |
| | | assertEquals(LDAPModify.run(System.out, System.err, args), LDAPResultCode.UNWILLING_TO_PERFORM); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** Tests the enter and leave lockdown mode tasks. */ |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | |
| | | // Create a file that holds the LDIF for putting the server in lockdown |
| | |
| | | "--noPropertiesFile", |
| | | "-f", taskFile |
| | | }; |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | |
| | | assertFalse(LDAPModify.run(nullPrintStream(), System.err, args) == 0); |
| | | |
| | | // If the local address isn't a loopback address, then verify that we can't |
| | | // put the server in lockdown mode using it. |
| | |
| | | "-Z", "-X", |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "--noPropertiesFile", |
| | | "--noPropertiesFile", |
| | | "-f", taskFile |
| | | }; |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertFalse(LDAPModify.run(nullPrintStream(), System.err, args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "-f", taskFile |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | waitTaskCompletedSuccessfully(taskDN); |
| | | assertTrue(DirectoryServer.lockdownMode()); |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | |
| | | // Make sure that we can no longer retrieve the server's root DSE over an |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertFalse(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args) == 0); |
| | | |
| | | |
| | | // Make sure that we can retrieve the server's root DSE over a |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, null), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | |
| | | |
| | | // Use another task to take the server out of lockdown mode and make sure it |
| | |
| | | "--noPropertiesFile", |
| | | "-f", taskFile |
| | | }; |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | waitTaskCompletedSuccessfully(taskDN); |
| | | assertFalse(DirectoryServer.lockdownMode()); |
| | | |
| | |
| | | "--noPropertiesFile", |
| | | "(objectClass=*)" |
| | | }; |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(LDAPSearch.run(nullPrintStream(), System.err, args), 0); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testLDAPCompare(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDAPCompare.mainCompare(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArg") |
| | | public void testLDAPDelete(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDAPDelete.mainDelete(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArg") |
| | | public void testLDAPModify(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDAPModify.mainModify(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArg") |
| | | public void testLDAPPasswordModify(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDAPPasswordModify.mainPasswordModify(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testLDAPSearch(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDAPSearch.mainSearch(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testLDIFDiff(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDIFDiff.mainDiff(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testLDIFModify(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDIFModify.ldifModifyMain(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArg") |
| | | public void testLDIFSearch(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(LDIFSearch.mainSearch(args, false, outStream, errStream)); |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidArgs") |
| | | public void testListBackends(final String[] args) |
| | | { |
| | | assertToolFailsWithUsage(ListBackends.listBackends(args, false, outStream, errStream)); |
| | |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.types.AcceptRejectWarn.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.LinkedList; |
| | |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test+description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test+description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: cn=test+description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | | "dn: description=foo,o=test", |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | |
| | | Entry e = TestCaseUtils.makeEntry( |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(e.conformsToSchema(null, false, true, true, invalidReason), |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import com.forgerock.opendj.ldap.tools.LDAPModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; |
| | | import com.forgerock.opendj.ldap.tools.LDAPSearch; |
| | | import org.opends.server.tools.RemoteConnection; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.types.Privilege.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | int resultCode = LDAPModify.mainModify(args, false, null, null); |
| | | int resultCode = LDAPModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | if (hasPrivilege) |
| | | { |
| | | assertEquals(resultCode, 0); |
| | |
| | | }; |
| | | |
| | | int resultCode = |
| | | LDAPPasswordModify.mainPasswordModify(args, false, null, null); |
| | | LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args); |
| | | if (hasPrivilege) |
| | | { |
| | | assertEquals(resultCode, 0); |
| | |
| | | "-a", "dn:cn=PWReset Target,o=test", |
| | | "-n", "password" |
| | | }; |
| | | assertEquals(LDAPPasswordModify.mainPasswordModify(args, false, null, |
| | | null), 0); |
| | | assertEquals(LDAPPasswordModify.run(nullPrintStream(), nullPrintStream(), args), 0); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | private int runSearch(String[] args) |
| | | { |
| | | return LDAPSearch.mainSearch(args, false, null, null); |
| | | return LDAPSearch.run(nullPrintStream(), nullPrintStream(), args); |
| | | } |
| | | |
| | | private int runSearchWithSystemErr(String[] args) |
| | | { |
| | | return LDAPSearch.mainSearch(args, false, null, System.err); |
| | | return LDAPSearch.run(nullPrintStream(), System.err, args); |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.Base64; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | "userCertificate;binary:: "+BASE64_CERT_VALUE |
| | | ); |
| | | StringBuilder builder = new StringBuilder(); |
| | | RawFilter.valueToFilterString(builder,ByteString.wrap(Base64.decode(BASE64_CERT_VALUE))); |
| | | RawFilter.valueToFilterString(builder, ByteString.wrap(Base64.decode(BASE64_CERT_VALUE).toByteArray())); |
| | | final String CERTIFICATE_ENCODED = builder.toString(); |
| | | |
| | | return new Object[][]{ |