| | |
| | | import org.opends.server.controls.PasswordPolicyResponseControl; |
| | | import org.opends.server.controls.PasswordPolicyWarningType; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | // The bind DN used for this bind operation. |
| | | private DN bindDN; |
| | | |
| | | // The DN of the user entry that is attempting to authenticate. |
| | | private DN userEntryDN; |
| | | |
| | | // The DN of the user as whom a SASL authentication was attempted (regardless |
| | | // of whether the authentication was successful) for the purpose of updating |
| | | // password policy state information. |
| | |
| | | this.saslCredentials = null; |
| | | |
| | | bindDN = null; |
| | | userEntryDN = null; |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | |
| | | this.simplePassword = null; |
| | | |
| | | bindDN = null; |
| | | userEntryDN = null; |
| | | responseControls = new ArrayList<Control>(0); |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | |
| | | pwPolicyErrorType = null; |
| | | pwPolicyWarningType = null; |
| | | pwPolicyWarningValue = -1; |
| | | userEntryDN = null; |
| | | } |
| | | |
| | | |
| | |
| | | authFailureID = 0; |
| | | authFailureReason = null; |
| | | saslAuthUserEntry = null; |
| | | userEntryDN = null; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the user entry DN for this bind operation. It will only be |
| | | * available if the bind processing has proceeded far enough to identify the |
| | | * user attempting to authenticate or if the user DN could not be determined. |
| | | * |
| | | * @return The user entry DN for this bind operation, or <CODE>null</CODE> if |
| | | * the bind processing has not progressed far enough to identify the |
| | | * user or if the user DN could not be determined. |
| | | */ |
| | | public DN getUserEntryDN() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getUserEntryDN"); |
| | | |
| | | return userEntryDN; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the time that processing started for this operation. |
| | | * |
| | | * @return The time that processing started for this operation. |
| | |
| | | setAuthFailureReason(msgID, message); |
| | | break bindProcessing; |
| | | } |
| | | else |
| | | { |
| | | userEntryDN = userEntry.getDN(); |
| | | } |
| | | |
| | | |
| | | // Check to see if the user has a password. If not, then fail. |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_EXPIRED, bindDN, msgID, |
| | | message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | else if (pwPolicyState.lockedDueToFailures()) |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_RESET_LOCKED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | else if (pwPolicyState.lockedDueToIdleInterval()) |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_IDLE_LOCKED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | } |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | } |
| | | else if (pwPolicyState.shouldWarn()) |
| | | { |
| | | int numSeconds = pwPolicyState.getSecondsUntilExpiration(); |
| | | String timeToExpiration = secondsToTimeString(numSeconds); |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeToExpiration); |
| | | appendErrorMessage(message); |
| | | |
| | | if (pwPolicyWarningType == null) |
| | | { |
| | | pwPolicyWarningType = |
| | | PasswordPolicyWarningType.TIME_BEFORE_EXPIRATION; |
| | | pwPolicyWarningValue = |
| | | pwPolicyState.getSecondsUntilExpiration(); |
| | | pwPolicyWarningValue = numSeconds; |
| | | } |
| | | |
| | | isFirstWarning = pwPolicyState.isFirstWarning(); |
| | |
| | | if (isFirstWarning) |
| | | { |
| | | pwPolicyState.setWarnedTime(); |
| | | |
| | | int numSeconds = pwPolicyState.getSecondsUntilExpiration(); |
| | | String timeToExpiration = secondsToTimeString(numSeconds); |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeToExpiration); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRING, bindDN, |
| | | msgID, message); |
| | | } |
| | | |
| | | if (isGraceLogin) |
| | |
| | | if (maxAllowedFailures > 0) |
| | | { |
| | | pwPolicyState.updateAuthFailureTimes(); |
| | | if (pwPolicyState.getAuthFailureTimes().size() > |
| | | if (pwPolicyState.getAuthFailureTimes().size() >= |
| | | maxAllowedFailures) |
| | | { |
| | | pwPolicyState.lockDueToFailures(); |
| | | |
| | | AccountStatusNotificationType notificationType; |
| | | |
| | | int lockoutDuration = pwPolicyState.getLockoutDuration(); |
| | | if (lockoutDuration > 0) |
| | | { |
| | | notificationType = AccountStatusNotificationType. |
| | | ACCOUNT_TEMPORARILY_LOCKED; |
| | | msgID = MSGID_BIND_ACCOUNT_TEMPORARILY_LOCKED; |
| | | message = getMessage(msgID, |
| | | secondsToTimeString(lockoutDuration)); |
| | | } |
| | | else |
| | | { |
| | | notificationType = AccountStatusNotificationType. |
| | | ACCOUNT_PERMANENTLY_LOCKED; |
| | | msgID = MSGID_BIND_ACCOUNT_PERMANENTLY_LOCKED; |
| | | message = getMessage(msgID); |
| | | } |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | notificationType, userEntryDN, msgID, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | // FIXME -- Need to have a way to enable debugging. |
| | | pwPolicyState = new PasswordPolicyState(saslAuthUserEntry, false, |
| | | false); |
| | | userDNString = String.valueOf(saslAuthUserEntry.getDN()); |
| | | userEntryDN = saslAuthUserEntry.getDN(); |
| | | userDNString = String.valueOf(userEntryDN); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | { |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_EXPIRED; |
| | | appendErrorMessage(getMessage(msgID, userDNString)); |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_EXPIRED; |
| | | String message = getMessage(msgID, userDNString); |
| | | appendErrorMessage(message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_EXPIRED, bindDN, msgID, |
| | | message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | |
| | |
| | | pwPolicyErrorType = PasswordPolicyErrorType.ACCOUNT_LOCKED; |
| | | } |
| | | |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_IDLE_LOCKED; |
| | | appendErrorMessage(getMessage(msgID, userDNString)); |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_IDLE_LOCKED; |
| | | String message = getMessage(msgID, userDNString); |
| | | appendErrorMessage(message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_IDLE_LOCKED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | |
| | |
| | | pwPolicyErrorType = PasswordPolicyErrorType.ACCOUNT_LOCKED; |
| | | } |
| | | |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_RESET_LOCKED; |
| | | appendErrorMessage(getMessage(msgID, userDNString)); |
| | | int msgID = MSGID_BIND_OPERATION_ACCOUNT_RESET_LOCKED; |
| | | String message = getMessage(msgID, userDNString); |
| | | appendErrorMessage(message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.ACCOUNT_RESET_LOCKED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | } |
| | |
| | | |
| | | setResultCode(ResultCode.INVALID_CREDENTIALS); |
| | | setAuthFailureReason(msgID, message); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRED, bindDN, |
| | | msgID, message); |
| | | |
| | | break bindProcessing; |
| | | } |
| | | } |
| | | else if (pwPolicyState.shouldWarn()) |
| | | { |
| | | int numSeconds = pwPolicyState.getSecondsUntilExpiration(); |
| | | String timeToExpiration = secondsToTimeString(numSeconds); |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeToExpiration); |
| | | appendErrorMessage(message); |
| | | |
| | | if (pwPolicyWarningType == null) |
| | | { |
| | | pwPolicyWarningType = |
| | | PasswordPolicyWarningType.TIME_BEFORE_EXPIRATION; |
| | | pwPolicyWarningValue = |
| | | pwPolicyState.getSecondsUntilExpiration(); |
| | | pwPolicyWarningValue = numSeconds; |
| | | } |
| | | |
| | | isFirstWarning = pwPolicyState.isFirstWarning(); |
| | |
| | | if (isFirstWarning) |
| | | { |
| | | pwPolicyState.setWarnedTime(); |
| | | |
| | | int numSeconds = pwPolicyState.getSecondsUntilExpiration(); |
| | | String timeToExpiration = secondsToTimeString(numSeconds); |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeToExpiration); |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | AccountStatusNotificationType.PASSWORD_EXPIRING, bindDN, |
| | | msgID, message); |
| | | } |
| | | |
| | | if (isGraceLogin) |
| | |
| | | if (maxAllowedFailures > 0) |
| | | { |
| | | pwPolicyState.updateAuthFailureTimes(); |
| | | if (pwPolicyState.getAuthFailureTimes().size() > |
| | | if (pwPolicyState.getAuthFailureTimes().size() >= |
| | | maxAllowedFailures) |
| | | { |
| | | pwPolicyState.lockDueToFailures(); |
| | | |
| | | AccountStatusNotificationType notificationType; |
| | | int msgID; |
| | | String message; |
| | | |
| | | int lockoutDuration = pwPolicyState.getLockoutDuration(); |
| | | if (lockoutDuration > 0) |
| | | { |
| | | notificationType = AccountStatusNotificationType. |
| | | ACCOUNT_TEMPORARILY_LOCKED; |
| | | msgID = MSGID_BIND_ACCOUNT_TEMPORARILY_LOCKED; |
| | | message = getMessage(msgID, |
| | | secondsToTimeString(lockoutDuration)); |
| | | } |
| | | else |
| | | { |
| | | notificationType = AccountStatusNotificationType. |
| | | ACCOUNT_PERMANENTLY_LOCKED; |
| | | msgID = MSGID_BIND_ACCOUNT_PERMANENTLY_LOCKED; |
| | | message = getMessage(msgID); |
| | | } |
| | | |
| | | pwPolicyState.generateAccountStatusNotification( |
| | | notificationType, userEntryDN, msgID, message); |
| | | } |
| | | } |
| | | } |