| | |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | 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 static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | public class InternalClientConnection |
| | | extends ClientConnection |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.internal." + |
| | | "InternalClientConnection"; |
| | | |
| | | |
| | | // The message ID counter to use for internal connections. |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | // This connection will be authenticated as a root user so that no |
| | | // access control will be enforced. |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", de); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, de); |
| | | } |
| | | |
| | | logError(ErrorLogCategory.CONNECTION_HANDLING, |
| | | ErrorLogSeverity.SEVERE_ERROR, |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(authInfo)); |
| | | |
| | | this.authenticationInfo = authInfo; |
| | | super.setAuthenticationInfo(authInfo); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public static InternalClientConnection getRootConnection() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getRootConnection"); |
| | | |
| | | return rootConnection; |
| | | } |
| | |
| | | */ |
| | | public static long nextOperationID() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "nextOperationID"); |
| | | |
| | | long opID = nextOperationID.getAndIncrement(); |
| | | if (opID < 0) |
| | |
| | | */ |
| | | public static 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 InternalConnectionHandler.getInstance(); |
| | | } |
| | |
| | | */ |
| | | public String getProtocol() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getProtocol"); |
| | | |
| | | return "internal"; |
| | | } |
| | |
| | | */ |
| | | public String getClientAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClientAddress"); |
| | | |
| | | return "internal"; |
| | | } |
| | |
| | | */ |
| | | public String getServerAddress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getServerAddress"); |
| | | |
| | | return "internal"; |
| | | } |
| | |
| | | */ |
| | | 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"); |
| | | |
| | | // Internal connections will generally be considered secure, but |
| | | // they may be declared insecure if they are accessed through some |
| | |
| | | */ |
| | | 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 |
| | |
| | | */ |
| | | 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 AuthenticationInfo getAuthenticationInfo() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAuthenticationInfo"); |
| | | |
| | | return authenticationInfo; |
| | | } |
| | |
| | | public void setAuthenticationInfo(AuthenticationInfo |
| | | authenticationInfo) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setAuthenticationInfo", |
| | | String.valueOf(authenticationInfo)); |
| | | |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public void setUnauthenticated() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setUnauthenticated"); |
| | | |
| | | // No implementation required. |
| | | } |
| | |
| | | public AddOperation processAdd(ByteString rawEntryDN, |
| | | List<LDAPAttribute> rawAttributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processAdd", |
| | | String.valueOf(rawEntryDN), |
| | | String.valueOf(rawAttributes)); |
| | | |
| | | AddOperation addOperation = |
| | | new AddOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | Map<AttributeType,List<Attribute>> |
| | | operationalAttributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processAdd", |
| | | String.valueOf(entryDN), |
| | | String.valueOf(objectClasses), |
| | | String.valueOf(userAttributes), |
| | | String.valueOf(operationalAttributes)); |
| | | |
| | | AddOperation addOperation = |
| | | new AddOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public BindOperation processSimpleBind(ByteString rawBindDN, |
| | | ByteString password) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSimpleBind", |
| | | String.valueOf(rawBindDN), "ByteString"); |
| | | |
| | | BindOperation bindOperation = |
| | | new BindOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public BindOperation processSimpleBind(DN bindDN, |
| | | ByteString password) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSimpleBind", |
| | | String.valueOf(bindDN), "ByteString"); |
| | | |
| | | BindOperation bindOperation = |
| | | new BindOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSASLBind", |
| | | String.valueOf(rawBindDN), |
| | | String.valueOf(saslMechanism), |
| | | "ASN1OctetString"); |
| | | |
| | | BindOperation bindOperation = |
| | | new BindOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSASLBind", |
| | | String.valueOf(bindDN), "ByteString"); |
| | | |
| | | BindOperation bindOperation = |
| | | new BindOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | String attributeType, |
| | | ByteString assertionValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processCompare", |
| | | String.valueOf(rawEntryDN), |
| | | String.valueOf(attributeType), |
| | | String.valueOf(assertionValue)); |
| | | |
| | | CompareOperation compareOperation = |
| | | new CompareOperation(this, nextOperationID(), |
| | |
| | | AttributeType attributeType, |
| | | ByteString assertionValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processCompare", |
| | | String.valueOf(entryDN), |
| | | String.valueOf(attributeType), |
| | | String.valueOf(assertionValue)); |
| | | |
| | | CompareOperation compareOperation = |
| | | new CompareOperation(this, nextOperationID(), |
| | |
| | | */ |
| | | public DeleteOperation processDelete(ByteString rawEntryDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processDelete", |
| | | String.valueOf(rawEntryDN)); |
| | | |
| | | DeleteOperation deleteOperation = |
| | | new DeleteOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | */ |
| | | public DeleteOperation processDelete(DN entryDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processDelete", |
| | | String.valueOf(entryDN)); |
| | | |
| | | 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(), |
| | |
| | | public ModifyOperation processModify(ByteString rawEntryDN, |
| | | List<LDAPModification> rawModifications) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModify", |
| | | String.valueOf(rawEntryDN), |
| | | String.valueOf(rawModifications)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | new ModifyOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | public ModifyOperation processModify(DN entryDN, |
| | | List<Modification> modifications) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModify", |
| | | String.valueOf(entryDN), |
| | | String.valueOf(modifications)); |
| | | |
| | | ModifyOperation modifyOperation = |
| | | new ModifyOperation(this, nextOperationID(), nextMessageID(), |
| | |
| | | ByteString 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, |
| | | ByteString rawNewSuperior) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModifyDN", |
| | | String.valueOf(rawEntryDN), |
| | | String.valueOf(rawNewRDN), |
| | | String.valueOf(deleteOldRDN), |
| | | String.valueOf(rawNewSuperior)); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | new ModifyDNOperation(this, nextOperationID(), |
| | |
| | | public ModifyDNOperation processModifyDN(DN entryDN, RDN newRDN, |
| | | boolean deleteOldRDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModifyDN", |
| | | String.valueOf(entryDN), |
| | | String.valueOf(newRDN), |
| | | String.valueOf(deleteOldRDN)); |
| | | |
| | | return processModifyDN(entryDN, newRDN, deleteOldRDN, null); |
| | | } |
| | |
| | | boolean deleteOldRDN, |
| | | DN newSuperior) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processModifyDN", |
| | | String.valueOf(entryDN), String.valueOf(newRDN), |
| | | String.valueOf(deleteOldRDN), |
| | | String.valueOf(newSuperior)); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | new ModifyDNOperation(this, nextOperationID(), |
| | |
| | | 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, |
| | |
| | | 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(), |
| | |
| | | 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(), |
| | |
| | | SearchScope scope, |
| | | SearchFilter filter) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", |
| | | String.valueOf(baseDN), |
| | | String.valueOf(scope), String.valueOf(filter)); |
| | | |
| | | return processSearch(baseDN, scope, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, |
| | |
| | | boolean typesOnly, SearchFilter filter, |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", |
| | | new String[] |
| | | { |
| | | String.valueOf(baseDN), |
| | | 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(), |
| | |
| | | LinkedHashSet<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "processSearch", |
| | | new String[] |
| | | { |
| | | String.valueOf(baseDN), |
| | | 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(), |
| | |
| | | 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 internal intermediate responses? |
| | |
| | | boolean sendNotification, String message, |
| | | int messageID) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "disconnect", |
| | | String.valueOf(disconnectReason), |
| | | String.valueOf(sendNotification), |
| | | String.valueOf(message), |
| | | String.valueOf(messageID)); |
| | | |
| | | // No implementation is required since there is nothing to |
| | | // disconnect. Further, since there is no real disconnect, we can |
| | |
| | | */ |
| | | public boolean bindInProgress() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "bindInProgress"); |
| | | |
| | | // For internal 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)); |
| | | |
| | | // Internal 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 internal operations will |
| | | // not be tracked. |
| | |
| | | public CancelResult cancelOperation(int messageID, |
| | | CancelRequest cancelRequest) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "cancelOperation", |
| | | String.valueOf(messageID), |
| | | String.valueOf(cancelRequest)); |
| | | |
| | | // Internal 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 internal 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 internal operations cannot |
| | | // be cancelled. |
| | |
| | | */ |
| | | public String getMonitorSummary() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMonitorSummary"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append("connID=\""); |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", |
| | | "java.lang.StringBuilder"); |
| | | |
| | | buffer.append("InternalClientConnection(connID="); |
| | | buffer.append(connectionID); |