001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2010 Sun Microsystems, Inc.
015 * Portions Copyright 2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.ldap.controls;
018
019/**
020 * A password policy warning type as defined in
021 * draft-behera-ldap-password-policy is used to indicate the current state of a
022 * user's password. More specifically, the number of seconds before a password
023 * will expire, or the remaining number of times a user will be allowed to
024 * authenticate with an expired password.
025 *
026 * @see PasswordPolicyRequestControl
027 * @see PasswordPolicyResponseControl
028 * @see PasswordPolicyErrorType
029 * @see <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy">
030 *      draft-behera-ldap-password-policy - Password Policy for LDAP Directories
031 *      </a>
032 */
033public enum PasswordPolicyWarningType {
034    /** Indicates the number of seconds before a password will expire. */
035    TIME_BEFORE_EXPIRATION(0, "timeBeforeExpiration"),
036
037    /**
038     * Indicates the remaining number of times a user will be allowed to
039     * authenticate with an expired password.
040     */
041    GRACE_LOGINS_REMAINING(1, "graceAuthNsRemaining");
042
043    private final int intValue;
044
045    private final String name;
046
047    private PasswordPolicyWarningType(final int intValue, final String name) {
048        this.intValue = intValue;
049        this.name = name;
050    }
051
052    @Override
053    public String toString() {
054        return name;
055    }
056
057    /**
058     * Returns the integer value for this password policy warning type.
059     *
060     * @return The integer value for this password policy warning type.
061     */
062    int intValue() {
063        return intValue;
064    }
065}