| | |
| | | // The set of all operations currently in progress on this connection. |
| | | private ConcurrentHashMap<Integer,Operation> operationsInProgress; |
| | | |
| | | // The connection security provider that was in use for the client connection |
| | | // before switching to a TLS-based provider. |
| | | private ConnectionSecurityProvider clearSecurityProvider; |
| | | |
| | | // The connection security provider for this client connection. |
| | | private ConnectionSecurityProvider securityProvider; |
| | | |
| | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(connectionHandler), |
| | | String.valueOf(clientChannel)); |
| | | |
| | | this.connectionHandler = connectionHandler; |
| | | this.clientChannel = clientChannel; |
| | | this.securityProvider = null; |
| | | this.connectionHandler = connectionHandler; |
| | | this.clientChannel = clientChannel; |
| | | this.securityProvider = null; |
| | | this.clearSecurityProvider = null; |
| | | |
| | | opsInProgressLock = new ReentrantLock(); |
| | | transmitLock = new ReentrantLock(); |
| | |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendResponse", String.valueOf(operation)); |
| | | |
| | | LDAPMessage message = operationToResponseLDAPMessage(operation); |
| | | if (message != null) |
| | | { |
| | | sendLDAPMessage(securityProvider, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves an LDAPMessage containing a response generated from the provided |
| | | * operation. |
| | | * |
| | | * @param operation The operation to use to generate the response |
| | | * LDAPMessage. |
| | | * |
| | | * @return An LDAPMessage containing a response generated from the provided |
| | | * operation. |
| | | */ |
| | | private LDAPMessage operationToResponseLDAPMessage(Operation operation) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "operationToResponseLDAPMessage", |
| | | String.valueOf(operation)); |
| | | |
| | | ResultCode resultCode = operation.getResultCode(); |
| | | if (resultCode == null) |
| | | { |
| | |
| | | ErrorLogSeverity.MILD_WARNING, |
| | | MSGID_LDAPV2_SKIPPING_EXTENDED_RESPONSE, |
| | | getConnectionID(), String.valueOf(operation)); |
| | | return; |
| | | return null; |
| | | } |
| | | |
| | | ExtendedOperation extOp = (ExtendedOperation) operation; |
| | |
| | | logError(ErrorLogCategory.REQUEST_HANDLING, ErrorLogSeverity.MILD_ERROR, |
| | | MSGID_LDAP_CLIENT_SEND_RESPONSE_INVALID_OP, |
| | | String.valueOf(operation)); |
| | | return; |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | sendLDAPMessage(new LDAPMessage(operation.getMessageID(), protocolOp, |
| | | controls)); |
| | | return new LDAPMessage(operation.getMessageID(), protocolOp, controls); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | sendLDAPMessage(new LDAPMessage(searchOperation.getMessageID(), protocolOp, |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(searchOperation.getMessageID(), protocolOp, |
| | | controls)); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | sendLDAPMessage(new LDAPMessage(searchOperation.getMessageID(), protocolOp, |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(searchOperation.getMessageID(), protocolOp, |
| | | controls)); |
| | | return true; |
| | | } |
| | |
| | | |
| | | LDAPMessage message = new LDAPMessage(operation.getMessageID(), protocolOp, |
| | | ldapControls); |
| | | sendLDAPMessage(message); |
| | | sendLDAPMessage(securityProvider, message); |
| | | |
| | | |
| | | // The only reason we shouldn't continue processing is if the connection is |
| | |
| | | /** |
| | | * Sends the provided LDAP message to the client. |
| | | * |
| | | * @param message The LDAP message to send to the client. |
| | | * @param securityProvider The connection security provider to use to |
| | | * handle any necessary security translation. |
| | | * @param message The LDAP message to send to the client. |
| | | */ |
| | | private void sendLDAPMessage(LDAPMessage message) |
| | | private void sendLDAPMessage(ConnectionSecurityProvider secProvider, |
| | | LDAPMessage message) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendLDAPMessage", String.valueOf(message)); |
| | | |
| | |
| | | try |
| | | { |
| | | int bytesWritten = messageBuffer.limit() - messageBuffer.position(); |
| | | if (! securityProvider.writeData(messageBuffer)) |
| | | if (! secProvider.writeData(messageBuffer)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | new AddResponseProtocolOp(de.getResultCode().getIntValue(), |
| | | de.getErrorMessage(), de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | new BindResponseProtocolOp( |
| | | LDAPResultCode.INAPPROPRIATE_AUTHENTICATION, |
| | | getMessage(MSGID_LDAPV2_CLIENTS_NOT_ALLOWED)); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | disconnect(DisconnectReason.PROTOCOL_ERROR, false, null, -1); |
| | | return false; |
| | | } |
| | |
| | | new BindResponseProtocolOp(de.getResultCode().getIntValue(), |
| | | de.getErrorMessage(), de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | |
| | | // If it was a protocol error, then terminate the connection. |
| | | if (de.getResultCode() == ResultCode.PROTOCOL_ERROR) |
| | |
| | | de.getErrorMessage(), |
| | | de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | new DeleteResponseProtocolOp(de.getResultCode().getIntValue(), |
| | | de.getErrorMessage(), de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | de.getErrorMessage(), |
| | | de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | new ModifyResponseProtocolOp(de.getResultCode().getIntValue(), |
| | | de.getErrorMessage(), de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | de.getErrorMessage(), |
| | | de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | de.getErrorMessage(), |
| | | de.getMatchedDN(), |
| | | de.getReferralURLs()); |
| | | sendLDAPMessage(new LDAPMessage(message.getMessageID(), responseOp)); |
| | | sendLDAPMessage(securityProvider, |
| | | new LDAPMessage(message.getMessageID(), responseOp)); |
| | | } |
| | | |
| | | |
| | |
| | | message, msgID); |
| | | } |
| | | |
| | | securityProvider = tlsSecurityProvider; |
| | | clearSecurityProvider = securityProvider; |
| | | securityProvider = tlsSecurityProvider; |
| | | } |
| | | |
| | | |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends a response to the client in the clear rather than through the |
| | | * encrypted channel. This should only be used when processing the StartTLS |
| | | * extended operation to send the response in the clear after the TLS |
| | | * negotiation has already been initiated. |
| | | * |
| | | * @param operation The operation for which to send the response in the |
| | | * clear. |
| | | * |
| | | * |
| | | * @throws DirectoryException If a problem occurs while sending the response |
| | | * in the clear. |
| | | */ |
| | | public void sendClearResponse(Operation operation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "sendClearResponse", |
| | | String.valueOf(operation)); |
| | | |
| | | if (clearSecurityProvider == null) |
| | | { |
| | | int msgID = MSGID_LDAP_NO_CLEAR_SECURITY_PROVIDER; |
| | | String message = getMessage(msgID, toString()); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, msgID); |
| | | } |
| | | |
| | | sendLDAPMessage(clearSecurityProvider, |
| | | operationToResponseLDAPMessage(operation)); |
| | | } |
| | | } |
| | | |