| | |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation ; |
| | | import org.opends.server.protocols.internal.InternalSearchListener; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DereferencePolicy; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.IntermediateResponse; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.SearchScope; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | |
| | | |
| | |
| | | public class JmxClientConnection |
| | | extends ClientConnection implements NotificationListener |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.jmx.JmxClientConnection"; |
| | | |
| | | |
| | | // The message ID counter to use for jmx connections. |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | nextMessageID = new AtomicInteger(1); |
| | | nextOperationID = new AtomicLong(0); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | // |
| | |
| | | */ |
| | | public long nextOperationID() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "nextOperationID"); |
| | | |
| | | long opID = nextOperationID.getAndIncrement(); |
| | | if (opID < 0) |
| | |
| | | */ |
| | | public int nextMessageID() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "nextMessageID"); |
| | | |
| | | int msgID = nextMessageID.getAndIncrement(); |
| | | if (msgID < 0) |
| | |
| | | */ |
| | | public long getConnectionID() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConnectionID"); |
| | | |
| | | return connectionID; |
| | | } |
| | |
| | | */ |
| | | public ConnectionHandler getConnectionHandler() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConnectionHandler"); |
| | | |
| | | return jmxConnectionHandler; |
| | | } |
| | |
| | | */ |
| | | public String getProtocol() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getProtocol"); |
| | | |
| | | return "jmx"; |
| | | } |
| | |
| | | */ |
| | | public String getClientAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClientAddress"); |
| | | |
| | | return "jmx"; |
| | | } |
| | |
| | | */ |
| | | public String getServerAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getServerAddress"); |
| | | |
| | | return "jmx"; |
| | | } |
| | |
| | | */ |
| | | public InetAddress getRemoteAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getRemoteAddress"); |
| | | |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | public InetAddress getLocalAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getLocalAddress"); |
| | | |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | public boolean isSecure() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isSecure"); |
| | | |
| | | return securityProvider.isSecure(); |
| | | } |
| | |
| | | */ |
| | | public ConnectionSecurityProvider getConnectionSecurityProvider() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConnectionSecurityProvider"); |
| | | |
| | | return securityProvider; |
| | | } |
| | |
| | | public void setConnectionSecurityProvider(ConnectionSecurityProvider |
| | | securityProvider) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setConnectionSecurityProvider", |
| | | String.valueOf(securityProvider)); |
| | | |
| | | this.securityProvider = securityProvider; |
| | | } |
| | |
| | | */ |
| | | public String getSecurityMechanism() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSecurityMechanism"); |
| | | |
| | | return securityProvider.getSecurityMechanismName(); |
| | | } |
| | |
| | | */ |
| | | public boolean processDataRead(ByteBuffer buffer) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processDataRead"); |
| | | |
| | | // This method will not do anything with the data because there is no |
| | | // actual "connection" from which information can be read, nor any protocol |
| | |
| | | */ |
| | | public void sendResponse(Operation operation) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendResponse", String.valueOf(operation)); |
| | | |
| | | // There will not be any response sent by this method, since there is not an |
| | | // actual connection. |
| | |
| | | public AddOperation processAdd(ASN1OctetString rawEntryDN, |
| | | ArrayList<LDAPAttribute> rawAttributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processAdd", String.valueOf(rawEntryDN), |
| | | String.valueOf(rawAttributes)); |
| | | |
| | | AddOperation addOperation = |
| | | new AddOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | String attributeType, |
| | | ASN1OctetString assertionValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processCompare", String.valueOf(rawEntryDN), |
| | | String.valueOf(attributeType), |
| | | String.valueOf(assertionValue)); |
| | | |
| | | CompareOperation compareOperation = |
| | | new CompareOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | */ |
| | | public DeleteOperation processDelete(ASN1OctetString rawEntryDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processDelete", |
| | | String.valueOf(rawEntryDN)); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | new DeleteOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public ExtendedOperation processExtendedOperation(String requestOID, |
| | | ASN1OctetString requestValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processExtendedOperation", |
| | | String.valueOf(requestOID), |
| | | String.valueOf(requestValue)); |
| | | |
| | | ExtendedOperation extendedOperation = |
| | | new ExtendedOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public ModifyOperation processModify(ASN1OctetString rawEntryDN, |
| | | ArrayList<LDAPModification> rawModifications) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModify", String.valueOf(rawEntryDN), |
| | | String.valueOf(rawModifications)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | new ModifyOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | ASN1OctetString rawNewRDN, |
| | | boolean deleteOldRDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModifyDN", |
| | | String.valueOf(rawEntryDN), String.valueOf(rawNewRDN), |
| | | String.valueOf(deleteOldRDN)); |
| | | |
| | | return processModifyDN(rawEntryDN, rawNewRDN, deleteOldRDN, null); |
| | | } |
| | |
| | | boolean deleteOldRDN, |
| | | ASN1OctetString rawNewSuperior) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModifyDN", String.valueOf(rawEntryDN), |
| | | String.valueOf(rawNewRDN), String.valueOf(deleteOldRDN), |
| | | String.valueOf(rawNewSuperior)); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | new ModifyDNOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public InternalSearchOperation processSearch(ASN1OctetString rawBaseDN, |
| | | SearchScope scope, LDAPFilter filter) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", String.valueOf(rawBaseDN), |
| | | String.valueOf(scope), String.valueOf(filter)); |
| | | |
| | | return processSearch(rawBaseDN, scope, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | |
| | | boolean typesOnly, LDAPFilter filter, |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", |
| | | new String[] |
| | | { |
| | | String.valueOf(rawBaseDN), |
| | | String.valueOf(scope), |
| | | String.valueOf(derefPolicy), |
| | | String.valueOf(sizeLimit), |
| | | String.valueOf(timeLimit), |
| | | String.valueOf(typesOnly), |
| | | String.valueOf(filter), |
| | | String.valueOf(attributes) |
| | | }); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | LinkedHashSet<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", |
| | | new String[] |
| | | { |
| | | String.valueOf(rawBaseDN), |
| | | String.valueOf(scope), |
| | | String.valueOf(derefPolicy), |
| | | String.valueOf(sizeLimit), |
| | | String.valueOf(timeLimit), |
| | | String.valueOf(typesOnly), |
| | | String.valueOf(filter), |
| | | String.valueOf(attributes), |
| | | String.valueOf(searchListener) |
| | | }); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public void sendSearchEntry(SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendSearchEntry", |
| | | String.valueOf(searchOperation), |
| | | String.valueOf(searchEntry)); |
| | | |
| | | ((InternalSearchOperation) searchOperation).addSearchEntry(searchEntry); |
| | | } |
| | |
| | | public boolean sendSearchReference(SearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendSearchReference", |
| | | String.valueOf(searchOperation), |
| | | String.valueOf(searchReference)); |
| | | |
| | | |
| | | ((InternalSearchOperation) |
| | |
| | | protected boolean sendIntermediateResponseMessage( |
| | | IntermediateResponse intermediateResponse) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendIntermediateResponseMessage", |
| | | String.valueOf(intermediateResponse)); |
| | | |
| | | |
| | | // FIXME -- Do we need to support Jmx intermediate responses? If so, |
| | |
| | | boolean sendNotification, String message, |
| | | int messageID) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "disconnect", |
| | | String.valueOf(disconnectReason), |
| | | String.valueOf(sendNotification), String.valueOf(message), |
| | | String.valueOf(messageID)); |
| | | |
| | | // we are already performing a disconnect |
| | | if (disconnectStarted) |
| | |
| | | catch (Exception e) |
| | | { |
| | | // TODO print a message ? |
| | | assert debugException(CLASS_NAME, "disconnect", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | // Call postDisconnectPlugins |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "disconnect", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public boolean bindInProgress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "bindInProgress"); |
| | | |
| | | // For Jmx operations, we don't care if there are any binds in |
| | | // progress. |
| | |
| | | */ |
| | | public void setBindInProgress(boolean bindInProgress) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setBindInProgress", |
| | | String.valueOf(bindInProgress)); |
| | | |
| | | // No implementation is required. |
| | | } |
| | |
| | | */ |
| | | public Collection<Operation> getOperationsInProgress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOperationsInProgress"); |
| | | |
| | | return operationList; |
| | | } |
| | |
| | | */ |
| | | public Operation getOperationInProgress(int messageID) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOperationInProgress", |
| | | String.valueOf(messageID)); |
| | | |
| | | // Jmx operations will not be tracked. |
| | | return null; |
| | |
| | | */ |
| | | public boolean removeOperationInProgress(int messageID) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "removeOperationInProgress", |
| | | String.valueOf(messageID)); |
| | | |
| | | // No implementation is required, since Jmx operations will not be |
| | | // tracked. |
| | |
| | | public CancelResult cancelOperation(int messageID, |
| | | CancelRequest cancelRequest) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "cancelOperation", |
| | | String.valueOf(messageID), |
| | | String.valueOf(cancelRequest)); |
| | | |
| | | // Jmx operations cannot be cancelled. |
| | | return CancelResult.CANNOT_CANCEL; |
| | |
| | | */ |
| | | public void cancelAllOperations(CancelRequest cancelRequest) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "cancelAllOperations", |
| | | String.valueOf(cancelRequest)); |
| | | |
| | | // No implementation is required since Jmx operations cannot be |
| | | // cancelled. |
| | |
| | | public void cancelAllOperationsExcept(CancelRequest cancelRequest, |
| | | int messageID) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "cancelAllOperationsExcept", |
| | | String.valueOf(cancelRequest), |
| | | String.valueOf(messageID)); |
| | | |
| | | // No implementation is required since Jmx operations cannot be |
| | | // cancelled. |
| | |
| | | */ |
| | | public String getMonitorSummary() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMonitorSummary"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append("connID=\""); |