001/*
002 * Copyright 2020-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2020-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2020-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds;
037
038
039
040import com.unboundid.util.Debug;
041import com.unboundid.util.NotNull;
042import com.unboundid.util.Nullable;
043import com.unboundid.util.StaticUtils;
044
045
046
047/**
048 * This enum defines the set of fields that are supported for use with the
049 * {@link ModifiablePasswordPolicyStateJSON} object.
050 * <BR>
051 * <BLOCKQUOTE>
052 *   <B>NOTE:</B>  This class, and other classes within the
053 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
054 *   supported for use against Ping Identity, UnboundID, and
055 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
056 *   for proprietary functionality or for external specifications that are not
057 *   considered stable or mature enough to be guaranteed to work in an
058 *   interoperable way with other types of LDAP servers.
059 * </BLOCKQUOTE>
060 */
061public enum ModifiablePasswordPolicyStateJSONField
062{
063  /**
064   * The field (password-changed-time) used to hold the time the user's password
065   * was last changed.  If present, the value of this field may be a string
066   * containing a timestamp in the ISO 8601 format described in RFC 3339, or it
067   * may be the JSON null value to indicate that the user does not have a
068   * password changed time.  Note that setting this field to {@code null} will
069   * cause the server to fall back to using the entry's createTimestamp value
070   * (if available) as the last changed time.
071   */
072  PASSWORD_CHANGED_TIME("password-changed-time"),
073
074
075
076  /**
077   * The field (account-is-disabled) used to indicate whether the user's account
078   * has been administratively disabled.
079   */
080  ACCOUNT_IS_DISABLED("account-is-disabled"),
081
082
083
084  /**
085   * The field (account-activation-time) used to hold the user's account
086   * activation time.  If present, the value of this field may be a string
087   * containing a timestamp in the ISO 8601 format described in RFC 3339, or it
088   * may be the JSON null value to indicate that the user does not have an
089   * account activation time.
090   */
091  ACCOUNT_ACTIVATION_TIME("account-activation-time"),
092
093
094
095  /**
096   * The field (account-expiration-time) used to hold the user's account
097   * expiration time.  If present, the value of this field may be a string
098   * containing a timestamp in the ISO 8601 format described in RFC 3339, or it
099   * may be the JSON null value to indicate that the user does not have an
100   * account expiration time.
101   */
102  ACCOUNT_EXPIRATION_TIME("account-expiration-time"),
103
104
105
106  /**
107   * The field (account-is-failure-locked) used to indicate whether the user's
108   * account is locked as a result of too many failed authentication attempts.
109   */
110  ACCOUNT_IS_FAILURE_LOCKED("account-is-failure-locked"),
111
112
113
114  /**
115   * The field (password-expiration-warned-time) used to hold the time that the
116   * user was first warned about an upcoming password expiration.  If present,
117   * the value of this field may be a string containing a timestamp in the ISO
118   * 8601 format described in RFC 3339, or it may be the JSON null value to
119   * indicate that the user does not have a password expiration warned time.
120   */
121  PASSWORD_EXPIRATION_WARNED_TIME("password-expiration-warned-time"),
122
123
124
125  /**
126   * The field (must-change-password) used to indicate whether the user must
127   * change their password before they will be permitted to request any other
128   * operations in the server.
129   */
130  MUST_CHANGE_PASSWORD("must-change-password");
131
132
133
134  // The name for the JSON field.
135  @NotNull private final String fieldName;
136
137
138
139  /**
140   * Creates a new password policy state JSON field with the specified name.
141   *
142   * @param  fieldName  The name for the JSON field.
143   */
144  ModifiablePasswordPolicyStateJSONField(@NotNull final String fieldName)
145  {
146    this.fieldName = fieldName;
147  }
148
149
150
151  /**
152   * Retrieves the name for the JSON field.
153   *
154   * @return  The name for the JSON field.
155   */
156  @NotNull()
157  public String getFieldName()
158  {
159    return fieldName;
160  }
161
162
163
164  /**
165   * Retrieves the modifiable password policy state JSON field value with the
166   * specified name.
167   *
168   * @param  name  The name of the password policy state JSON field value to
169   *               retrieve.  It must not be {@code null}.
170   *
171   * @return  The modifiable password policy state JSON field value with the
172   *          specified name, or {@code null} if there is no value with the
173   *          specified name.
174   */
175  @Nullable()
176  public static ModifiablePasswordPolicyStateJSONField forName(
177              @NotNull final String name)
178  {
179    try
180    {
181      final String transformedName =
182           StaticUtils.toUpperCase(name).replace('-', '_');
183      return valueOf(transformedName);
184    }
185    catch (final Exception e)
186    {
187      Debug.debugException(e);
188      return null;
189    }
190  }
191
192
193
194  /**
195   * Retrieves a string representation of this modifiable password policy state
196   * JSON field.
197   *
198   * @return  A string representation of this password policy state JSON field.
199   */
200  @Override()
201  @NotNull()
202  public String toString()
203  {
204    return fieldName;
205  }
206}