| | |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | |
| | | |
| | | import static org.opends.server.core.CoreConstants.LOG_ELEMENT_AUTH_TYPE; |
| | |
| | | import static org.opends.server.loggers.AccessLogger.logBindRequest; |
| | | import static org.opends.server.loggers.AccessLogger.logBindResponse; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.OperationType; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.operation.PreParseBindOperation; |
| | | import org.opends.server.workflowelement.localbackend.*; |
| | | |
| | |
| | | // password policy state information. |
| | | private Entry saslAuthUserEntry; |
| | | |
| | | // The unique ID associated with the failure reason message. |
| | | private int authFailureID; |
| | | |
| | | // The set of response controls for this bind operation. |
| | | private List<Control> responseControls; |
| | | |
| | | // A message explaining the reason for the authentication failure. |
| | | private String authFailureReason; |
| | | private Message authFailureReason; |
| | | |
| | | // The SASL mechanism used for SASL authentication. |
| | | private String saslMechanism; |
| | |
| | | bindDN = null; |
| | | userEntryDN = null; |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | | saslAuthUserEntry = null; |
| | | } |
| | |
| | | bindDN = null; |
| | | userEntryDN = null; |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | | saslAuthUserEntry = null; |
| | | } |
| | |
| | | } |
| | | |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | | saslAuthUserEntry = null; |
| | | userEntryDN = null; |
| | |
| | | } |
| | | |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | | saslAuthUserEntry = null; |
| | | userEntryDN = null; |
| | |
| | | } |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(de.getMessageID(), de.getErrorMessage()); |
| | | setAuthFailureReason(de.getMessageObject()); |
| | | } |
| | | return bindDN; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final String getAuthFailureReason() |
| | | public final Message getAuthFailureReason() |
| | | { |
| | | return authFailureReason; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final int getAuthFailureID() |
| | | { |
| | | return authFailureID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final void setAuthFailureReason(int id, String reason) |
| | | public final void setAuthFailureReason(Message message) |
| | | { |
| | | if (DirectoryServer.returnBindErrorMessages()) |
| | | { |
| | | appendErrorMessage(reason); |
| | | appendErrorMessage(message); |
| | | } |
| | | else |
| | | { |
| | | if (id < 0) |
| | | { |
| | | authFailureID = 0; |
| | | } |
| | | else |
| | | { |
| | | authFailureID = id; |
| | | } |
| | | |
| | | authFailureReason = reason; |
| | | authFailureReason = message; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override() |
| | | public final void disconnectClient(DisconnectReason disconnectReason, |
| | | boolean sendNotification, String message, |
| | | int messageID) |
| | | boolean sendNotification, Message message |
| | | ) |
| | | { |
| | | // Since bind operations can't be cancelled, we don't need to do anything |
| | | // but forward the request on to the client connection. |
| | | clientConnection.disconnect(disconnectReason, sendNotification, message, |
| | | messageID); |
| | | clientConnection.disconnect(disconnectReason, sendNotification, |
| | | message); |
| | | } |
| | | |
| | | /** |
| | |
| | | String resultCode = String.valueOf(getResultCode().getIntValue()); |
| | | |
| | | String errorMessage; |
| | | StringBuilder errorMessageBuffer = getErrorMessage(); |
| | | MessageBuilder errorMessageBuffer = getErrorMessage(); |
| | | if (errorMessageBuffer == null) |
| | | { |
| | | errorMessage = null; |
| | |
| | | @Override() |
| | | public final CancelResult cancel(CancelRequest cancelRequest) |
| | | { |
| | | cancelRequest.addResponseMessage(getMessage(MSGID_CANNOT_CANCEL_BIND)); |
| | | cancelRequest.addResponseMessage(ERR_CANNOT_CANCEL_BIND.get()); |
| | | return CancelResult.CANNOT_CANCEL; |
| | | } |
| | | |
| | |
| | | clientConnection.setUnauthenticated(); |
| | | |
| | | // Abandon any operations that may be in progress for the client. |
| | | String cancelReason = getMessage(MSGID_CANCELED_BY_BIND_REQUEST); |
| | | Message cancelReason = INFO_CANCELED_BY_BIND_REQUEST.get(); |
| | | CancelRequest cancelRequest = new CancelRequest(true, cancelReason); |
| | | clientConnection.cancelAllOperationsExcept(cancelRequest, getMessageID()); |
| | | |
| | |
| | | // result and return. |
| | | setResultCode(ResultCode.CANCELED); |
| | | |
| | | int msgID = MSGID_CANCELED_BY_PREPARSE_DISCONNECT; |
| | | appendErrorMessage(getMessage(msgID)); |
| | | appendErrorMessage(ERR_CANCELED_BY_PREPARSE_DISCONNECT.get()); |
| | | |
| | | setProcessingStopTime(); |
| | | |
| | |
| | | */ |
| | | private void updateOperationErrMsgAndResCode() |
| | | { |
| | | int msgID = MSGID_BIND_OPERATION_UNKNOWN_USER; |
| | | String message = getMessage(msgID, String.valueOf(getBindDN())); |
| | | |
| | | Message message = ERR_BIND_OPERATION_UNKNOWN_USER.get( |
| | | String.valueOf(getBindDN())); |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | setAuthFailureReason(message); |
| | | } |
| | | |
| | | } |