opendj3-server-dev/src/server/org/opends/server/api/ClientConnection.java
@@ -26,8 +26,6 @@ */ package org.opends.server.api; import java.net.InetAddress; import java.nio.channels.ByteChannel; import java.nio.channels.Selector; @@ -42,6 +40,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ByteString; import org.opends.server.api.plugin.PluginResult; import org.opends.server.core.DirectoryServer; import org.opends.server.core.PersistentSearch; @@ -50,7 +49,6 @@ import org.opends.server.core.networkgroups.NetworkGroup; import org.opends.server.types.Attribute; import org.opends.server.types.AttributeType; import org.forgerock.opendj.ldap.ByteString; import org.opends.server.types.AuthenticationInfo; import org.opends.server.types.CancelRequest; import org.opends.server.types.CancelResult; @@ -60,11 +58,9 @@ import org.opends.server.types.Entry; import org.opends.server.types.IntermediateResponse; import org.opends.server.types.Operation; import org.opends.server.types.OperationType; import org.opends.server.types.Privilege; import org.opends.server.types.SearchResultEntry; import org.opends.server.types.SearchResultReference; import org.opends.server.types.operation.PreParseOperation; import org.opends.server.util.TimeThread; import static org.opends.messages.CoreMessages.*; @@ -143,13 +139,6 @@ private final CopyOnWriteArrayList<PersistentSearch> persistentSearches; /** The network group to which the connection belongs to. */ private NetworkGroup networkGroup; /** Need to evaluate the network group for the first operation. */ protected boolean mustEvaluateNetworkGroup; /** * Performs the appropriate initialization generic to all client * connections. @@ -169,11 +158,6 @@ lookthroughLimit = DirectoryServer.getLookthroughLimit(); finalized = false; privileges = new HashSet<Privilege>(); networkGroup = NetworkGroup.getDefaultNetworkGroup(); networkGroup.addConnection(this); mustEvaluateNetworkGroup = true; logger.trace(INFO_CHANGE_NETWORK_GROUP, getConnectionID(), null, networkGroup.getID()); } @@ -226,8 +210,6 @@ DirectoryServer.getAuthenticatedUsers().remove( authZEntry.getName(), this); } networkGroup.removeConnection(this); } @@ -468,8 +450,6 @@ return 0L; } /** * Retrieves the total number of operations performed * on this connection. @@ -480,47 +460,6 @@ public abstract long getNumberOfOperations(); /** * Indicates whether the network group must be evaluated for * the next connection. * @param operation The operation going to be performed. Bind * operations imply a network group evaluation. * @return boolean indicating if the network group must be evaluated */ public boolean mustEvaluateNetworkGroup( PreParseOperation operation) { // Connections inside the internal network group MUST NOT // change network group if (this.networkGroup == NetworkGroup.getInternalNetworkGroup()) { return false; } // Connections inside the admin network group MUST NOT // change network group if (this.networkGroup == NetworkGroup.getAdminNetworkGroup()) { return false; } // If the operation is a BIND, the network group MUST be evaluated if (operation != null && operation.getOperationType() == OperationType.BIND) { return true; } return mustEvaluateNetworkGroup; } /** * Indicates that the network group will have to be evaluated * for the next connection. * * @param bool true if the network group must be evaluated */ public void mustEvaluateNetworkGroup(boolean bool) { mustEvaluateNetworkGroup = bool; } /** * Sends a response to the client based on the information in the * provided operation. * @@ -987,8 +926,6 @@ public void setUnauthenticated() { setAuthenticationInfo(new AuthenticationInfo()); this.sizeLimit = networkGroup.getSizeLimit(); this.timeLimit = networkGroup.getTimeLimit(); } @@ -1654,40 +1591,12 @@ * * @return the network group attached to the connection */ public final NetworkGroup getNetworkGroup() public NetworkGroup getNetworkGroup() { return networkGroup; return NetworkGroup.getDefaultNetworkGroup(); } /** * Sets the network group to which the connection belongs. * * @param networkGroup the network group to which the * connections belongs to */ public final void setNetworkGroup (NetworkGroup networkGroup) { if (this.networkGroup != networkGroup) { logger.trace(INFO_CHANGE_NETWORK_GROUP, getConnectionID(), this.networkGroup.getID(), networkGroup.getID()); // If there is a change, first remove this connection // from the current network group this.networkGroup.removeConnection(this); // Then set the new network group this.networkGroup = networkGroup; // And add the connection to the new ng this.networkGroup.addConnection(this); // The client connection inherits the resource limits sizeLimit = networkGroup.getSizeLimit(); timeLimit = networkGroup.getTimeLimit(); } } /** * Retrieves the length of time in milliseconds that this client * connection has been idle. * <BR><BR> opendj3-server-dev/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
@@ -33,7 +33,6 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.ResultCode; import org.opends.server.api.ClientConnection; import org.opends.server.core.DirectoryServer; import org.opends.server.core.RootDseWorkflowTopology; import org.opends.server.core.Workflow; @@ -221,16 +220,6 @@ } /** * Adds a connection to the group. * * @param connection * the ClientConnection */ public void addConnection(ClientConnection connection) { } /** * Deregisters a workflow with the network group. The workflow to * deregister is identified by its baseDN. * @@ -468,18 +457,6 @@ return workflowCandidate; } /** * Removes a connection from the group. * * @param connection * the ClientConnection */ public void removeConnection(ClientConnection connection) { } /** * Deregisters the current network group (this) with the server. The * method also decrements the reference counter of the workflows so opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -108,9 +108,6 @@ { super(); this.setNetworkGroup(NetworkGroup.getInternalNetworkGroup()); // This connection will be authenticated as a root user so that no // access control will be enforced. String commonName = "Internal Client"; @@ -211,8 +208,6 @@ { super(); this.setNetworkGroup(NetworkGroup.getInternalNetworkGroup()); // Don't call super.setAuthenticationInfo() since this will register this // connection in the authenticated users table, which is unnecessary and // will also cause the connection to be leaked since internal connections @@ -255,7 +250,12 @@ this(getAuthInfoForDN(userDN)); } /** {@inheritDoc} */ @Override public NetworkGroup getNetworkGroup() { return NetworkGroup.getInternalNetworkGroup(); } /** * Creates an authentication information object for the user with opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java
@@ -27,7 +27,8 @@ package org.opends.server.protocols.jmx; import java.net.InetAddress; import java.util.*; import java.util.Collection; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -87,8 +88,6 @@ { super(); setNetworkGroup(NetworkGroup.getAdminNetworkGroup()); nextMessageID = new AtomicInteger(1); nextOperationID = new AtomicLong(0); @@ -110,6 +109,12 @@ .addNotificationListener(this, null, null); } /** {@inheritDoc} */ @Override public NetworkGroup getNetworkGroup() { return NetworkGroup.getAdminNetworkGroup(); } /** {@inheritDoc} */ @Override opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -29,6 +29,7 @@ import java.io.Closeable; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.*; import java.security.cert.Certificate; @@ -468,11 +469,6 @@ SocketChannel clientChannel, String protocol) throws DirectoryException { this.connectionHandler = connectionHandler; if (connectionHandler.isAdminConnectionHandler()) { setNetworkGroup(NetworkGroup.getAdminNetworkGroup()); } this.clientChannel = clientChannel; timeoutClientChannel = new TimeoutWriteByteChannel(); opsInProgressLock = new Object(); @@ -486,15 +482,14 @@ keepStats = connectionHandler.keepStats(); this.protocol = protocol; writeSelector = new AtomicReference<Selector>(); clientAddress = clientChannel.socket().getInetAddress().getHostAddress(); clientPort = clientChannel.socket().getPort(); serverAddress = clientChannel.socket().getLocalAddress().getHostAddress(); serverPort = clientChannel.socket().getLocalPort(); statTracker = this.connectionHandler.getStatTracker(); final Socket socket = clientChannel.socket(); clientAddress = socket.getInetAddress().getHostAddress(); clientPort = socket.getPort(); serverAddress = socket.getLocalAddress().getHostAddress(); serverPort = socket.getLocalPort(); statTracker = this.connectionHandler.getStatTracker(); if (keepStats) { @@ -519,6 +514,17 @@ connectionID = DirectoryServer.newConnectionAccepted(this); } /** {@inheritDoc} */ @Override public NetworkGroup getNetworkGroup() { if (connectionHandler.isAdminConnectionHandler()) { return NetworkGroup.getAdminNetworkGroup(); } return NetworkGroup.getDefaultNetworkGroup(); } /** * Retrieves the connection ID assigned to this connection. * opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/WorkflowConfigurationTest.java
@@ -34,7 +34,6 @@ import org.forgerock.opendj.ldap.SearchScope; import org.opends.server.TestCaseUtils; import org.opends.server.api.Backend; import org.opends.server.api.ClientConnection; import org.opends.server.config.ConfigConstants; import org.opends.server.core.networkgroups.NetworkGroup; import org.opends.server.protocols.internal.InternalClientConnection; @@ -515,45 +514,4 @@ dsconfigRemoveMemoryBackend(backendID2); checkBackendIsNotAccessible(baseDN2); } /** * This test checks the creation and utilization of network group * in the route process. */ @Test public void useNetworkGroup() throws Exception { // Local settings String backendID = "test"; String baseDN = "o=test"; // Create a route for o=test suffix in the internal network group. // Search on o=test should succeed. WorkflowImpl workflowImpl = createWorkflow(baseDN, backendID); InternalSearchOperation searchOperation = doSearch(baseDN, SearchScope.BASE_OBJECT, ResultCode.SUCCESS); // Create a network group and store it in the client connection. // As the network group is empty, all searches should fail with a // no such object result code. String networkGroupID = "useNetworkGroupID"; NetworkGroup networkGroup = new NetworkGroup(networkGroupID); ClientConnection clientConnection = searchOperation.getClientConnection(); clientConnection.setNetworkGroup(networkGroup); searchOperation.run(); assertEquals(searchOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT); // Now register the o=test workflow and search again. The search // should succeed. networkGroup.registerWorkflow(workflowImpl); searchOperation.run(); assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); // Put back the internal network group in the client connection // and check that searches are still working. clientConnection.setNetworkGroup(NetworkGroup.getInternalNetworkGroup()); searchOperation.run(); assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); } }