| | |
| | | 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 |
| | |
| | | |
| | | |
| | | /** |
| | | * 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. |
| | | * |
| | |
| | | "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")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 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(), |
| | |
| | | |
| | | // 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(), |
| | |
| | | |
| | | // 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(), |
| | |
| | | |
| | | // 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(), |
| | |
| | | "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")); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 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); |
| | |
| | | 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) } |
| | | }; |
| | | } |
| | | |