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

neil_a_wilson
16.37.2007 06b521335fbe2a64d9d0840fedd8bc2fdd52e535
opends/src/messages/messages/protocol.properties
@@ -1404,3 +1404,4 @@
MILD_ERR_JMX_INSUFFICIENT_PRIVILEGES_439=You do not have sufficient \
 privileges to establish the connection through JMX. At least JMX_READ \
 privilege is required
MILD_ERR_INTERNALCONN_NO_SUCH_USER_440=User %s does not exist in the directory
opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -311,6 +311,67 @@
  /**
   * Creates a new internal client connection that will be
   * authenticated as the specified user.
   *
   * @param  userDN  The DN of the entry to use as the
   *                 authentication and authorization identity.
   *
   * @throws  DirectoryException  If a problem occurs while trying to
   *                              get the entry for the provided user
   *                              DN.
   */
  public InternalClientConnection(DN userDN)
         throws DirectoryException
  {
    this(getAuthInfoForDN(userDN));
  }
  /**
   * Creates an authentication information object for the user with
   * the specified DN.
   *
   * @param  userDN  The DN of the user for whom to create an
   *                 authentication information object.
   *
   * @return  The appropriate authentication information object.
   *
   * @throws  DirectoryException  If a problem occurs while trying to
   *                              create the authentication
   *                              information object, or there is no
   *                              such user in the directory.
   */
  private static AuthenticationInfo getAuthInfoForDN(DN userDN)
          throws DirectoryException
  {
    if ((userDN == null) || userDN.isNullDN())
    {
      return new AuthenticationInfo();
    }
    DN rootUserDN = DirectoryServer.getActualRootBindDN(userDN);
    if (rootUserDN != null)
    {
      userDN = rootUserDN;
    }
    Entry userEntry = DirectoryServer.getEntry(userDN);
    if (userEntry == null)
    {
      Message m =
           ERR_INTERNALCONN_NO_SUCH_USER.get(String.valueOf(userDN));
      throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m);
    }
    boolean isRoot = DirectoryServer.isRootDN(userDN);
    return new AuthenticationInfo(userEntry, isRoot);
  }
  /**
   * Retrieves a shared internal client connection that is
   * authenticated as a root user.
   *
opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
@@ -123,10 +123,8 @@
         "ds-privilege-name: bypass-acl",
         "ds-privilege-name: proxied-auth");
    Entry proxyUserEntry =
               DirectoryServer.getEntry(DN.decode("uid=proxy.user,o=test"));
    AuthenticationInfo authInfo = new AuthenticationInfo(proxyUserEntry, false);
    proxyUserConn = new InternalClientConnection(authInfo);
    proxyUserConn =
         new InternalClientConnection(DN.decode("uid=proxy.user,o=test"));
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/core/GroupManagerTestCase.java
@@ -1203,8 +1203,7 @@
    // Get a client connection authenticated as user1 and make sure it handles
    // group operations correctly.
    AuthenticationInfo authInfo = new AuthenticationInfo();
    InternalClientConnection conn0 = new InternalClientConnection(authInfo);
    InternalClientConnection conn0 = new InternalClientConnection(DN.nullDN());
    InternalSearchOperation searchOperation =
         new InternalSearchOperation(conn0, conn0.nextOperationID(),
                  conn0.nextMessageID(), null, DN.nullDN(),
@@ -1230,8 +1229,7 @@
    // Get a client connection authenticated as user1 and make sure it handles
    // group operations correctly.
    authInfo = new AuthenticationInfo(DirectoryServer.getEntry(user1DN), false);
    InternalClientConnection conn1 = new InternalClientConnection(authInfo);
    InternalClientConnection conn1 = new InternalClientConnection(user1DN);
    searchOperation =
         new InternalSearchOperation(conn1, conn1.nextOperationID(),
                  conn1.nextMessageID(), null, DN.nullDN(),
@@ -1261,8 +1259,7 @@
    // Get a client connection authenticated as user2 and make sure it handles
    // group operations correctly.
    authInfo = new AuthenticationInfo(DirectoryServer.getEntry(user2DN), false);
    InternalClientConnection conn2 = new InternalClientConnection(authInfo);
    InternalClientConnection conn2 = new InternalClientConnection(user2DN);
    searchOperation =
         new InternalSearchOperation(conn2, conn2.nextOperationID(),
                  conn2.nextMessageID(), null, DN.nullDN(),
@@ -1292,8 +1289,7 @@
    // Get a client connection authenticated as user3 and make sure it handles
    // group operations correctly.
    authInfo = new AuthenticationInfo(DirectoryServer.getEntry(user3DN), false);
    InternalClientConnection conn3 = new InternalClientConnection(authInfo);
    InternalClientConnection conn3 = new InternalClientConnection(user3DN);
    searchOperation =
         new InternalSearchOperation(conn3, conn3.nextOperationID(),
                  conn3.nextMessageID(), null, DN.nullDN(),
opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
@@ -153,10 +153,8 @@
         "ds-privilege-name: bypass-acl",
         "ds-privilege-name: proxied-auth");
    Entry proxyUserEntry =
               DirectoryServer.getEntry(DN.decode("uid=proxy.user,o=test"));
    AuthenticationInfo authInfo = new AuthenticationInfo(proxyUserEntry, false);
    proxyUserConn = new InternalClientConnection(authInfo);
    proxyUserConn =
         new InternalClientConnection(DN.decode("uid=proxy.user,o=test"));
  }
  /**
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java
@@ -104,12 +104,14 @@
  /**
   * Tests the use of the Who Am I? extended operation with an internal
   * unauthenticated connection.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAsInternalAnonymous()
         throws Exception
  {
    InternalClientConnection conn =
         new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(DN.nullDN());
    ExtendedOperation extOp =
         conn.processExtendedOperation(OID_WHO_AM_I_REQUEST, null);
    assertEquals(extOp.getResultCode(), ResultCode.SUCCESS);
opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
@@ -136,7 +136,10 @@
      new Object[] { new InternalClientConnection(
           new AuthenticationInfo(dmEntry, true)) },
      new Object[] { new InternalClientConnection(
           new AuthenticationInfo(userEntry, false)) }
           new AuthenticationInfo(userEntry, false)) },
      new Object[] { new InternalClientConnection(dmDN) },
      new Object[] { new InternalClientConnection(DN.nullDN()) },
      new Object[] { new InternalClientConnection((DN) null) }
    };
  }