mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Chris Ridd
01.29.2015 fe19ac2d6f1b978356b29e81901b91ae7a09daf9
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
@@ -199,6 +199,47 @@
    return oStream.toString();
  }
  /**
   * Perform a modify operation, and request attributes via a preRead control.
   *
   * @param bindDn        The user to authenticate as.
   * @param bindPassword  The user's credentials.
   * @param ldif          The modification to make.
   * @param attributes    A space-separated list of attributes to return.
   *
   * @return  The output of the command.
   *
   * @throws Exception  If an unexpected problem occurred.
   */
  protected String preReadModify(String bindDn, String bindPassword,
                                 String ldif, String attributes) throws Exception
  {
    File tempFile = getTemporaryLdifFile();
    TestCaseUtils.writeFile(tempFile, ldif);
    ArrayList<String> argList=new ArrayList<>(20);
    argList.add("-h");
    argList.add("127.0.0.1");
    argList.add("-p");
    argList.add(String.valueOf(TestCaseUtils.getServerLdapPort()));
    argList.add("-D");
    argList.add(bindDn);
    argList.add("-w");
    argList.add(bindPassword);
    if (attributes != null) {
      argList.add("--preReadAttributes");
      argList.add(attributes);
    }
    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();
  }
  protected String LDAPSearchCtrl(String bindDn, String bindPassword,
                            String proxyDN, String controlStr,
                            String base, String filter, String attr) {
@@ -719,26 +760,42 @@
  protected Map<String, String> getAttrMap(String resultString)
  {
    StringReader r=new StringReader(resultString);
    BufferedReader br=new BufferedReader(r);
    return getAttrMap(resultString, false);
  }
  /**
   * Parse a tool output for an LDIF record, returning the attributes in a Map.
   *
   * @param resultString The entire output from the operation
   * @param stripHeader  Set to {@code true} if data before the LDIF needs to be ignored
   * @return  A map of attribute-values
   */
  protected Map<String, String> getAttrMap(String resultString, boolean stripHeader)
  {
    StringReader r = new StringReader(resultString);
    BufferedReader br = new BufferedReader(r);
    boolean stripping = stripHeader;
    Map<String, String> attrMap = new HashMap<>();
    try {
      while(true) {
      while (true) {
        String s = br.readLine();
        if(s == null)
        if (s == null)
        {
          break;
        }
        if(s.startsWith("dn:"))
        {
        if (stripping) {
          if (s.startsWith("dn:"))
          {
            stripping = false;
          }
          continue;
        }
        String[] a=s.split(": ");
        if(a.length != 2)
        if (a.length != 2)
        {
          break;
        }
        attrMap.put(a[0].toLowerCase(),a[1]);
        attrMap.put(a[0].toLowerCase(), a[1]);
      }
    } catch (IOException e) {
      Assert.fail(e.getMessage());