001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2010 Sun Microsystems, Inc.
025 */
026package org.forgerock.opendj.ldap.controls;
027
028/**
029 * A password policy error type as defined in draft-behera-ldap-password-policy
030 * is used to indicate problems concerning a user's account or password.
031 *
032 * @see PasswordPolicyRequestControl
033 * @see PasswordPolicyResponseControl
034 * @see PasswordPolicyWarningType
035 * @see <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy">
036 *      draft-behera-ldap-password-policy - Password Policy for LDAP Directories
037 *      </a>
038 */
039public enum PasswordPolicyErrorType {
040
041    /**
042     * Indicates that the password has expired and must be reset.
043     */
044    PASSWORD_EXPIRED(0, "passwordExpired"),
045
046    /**
047     * Indicates that the user's account has been locked.
048     */
049    ACCOUNT_LOCKED(1, "accountLocked"),
050
051    /**
052     * Indicates that the password must be changed before the user will be
053     * allowed to perform any operation other than bind and modify.
054     */
055    CHANGE_AFTER_RESET(2, "changeAfterReset"),
056
057    /**
058     * Indicates that a user is restricted from changing her password.
059     */
060    PASSWORD_MOD_NOT_ALLOWED(3, "passwordModNotAllowed"),
061
062    /**
063     * Indicates that the old password must be supplied in order to modify the
064     * password.
065     */
066    MUST_SUPPLY_OLD_PASSWORD(4, "mustSupplyOldPassword"),
067
068    /**
069     * Indicates that a password doesn't pass quality checking.
070     */
071    INSUFFICIENT_PASSWORD_QUALITY(5, "insufficientPasswordQuality"),
072
073    /**
074     * Indicates that a password is not long enough.
075     */
076    PASSWORD_TOO_SHORT(6, "passwordTooShort"),
077
078    /**
079     * Indicates that the age of the password to be modified is not yet old
080     * enough.
081     */
082    PASSWORD_TOO_YOUNG(7, "passwordTooYoung"),
083
084    /**
085     * Indicates that a password has already been used and the user must choose
086     * a different one.
087     */
088    PASSWORD_IN_HISTORY(8, "passwordInHistory");
089
090    private final int intValue;
091
092    private final String name;
093
094    private PasswordPolicyErrorType(final int intValue, final String name) {
095        this.intValue = intValue;
096        this.name = name;
097    }
098
099    /** {@inheritDoc} */
100    @Override
101    public String toString() {
102        return name;
103    }
104
105    /**
106     * Returns the integer value for this password policy error type.
107     *
108     * @return The integer value for this password policy error type.
109     */
110    int intValue() {
111        return intValue;
112    }
113
114}