001/*
002 * Copyright 2015-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2015-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) 2015-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.extensions;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This enum specifies the modes in which the get password quality requirements
050 * extended operation may determine the type of password update operation that
051 * will be performed and the way in which the server should determine which
052 * password policy to use in order to obtain the password quality requirements.
053 * <BR>
054 * <BLOCKQUOTE>
055 *   <B>NOTE:</B>  This class, and other classes within the
056 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
057 *   supported for use against Ping Identity, UnboundID, and
058 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
059 *   for proprietary functionality or for external specifications that are not
060 *   considered stable or mature enough to be guaranteed to work in an
061 *   interoperable way with other types of LDAP servers.
062 * </BLOCKQUOTE>
063 */
064@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
065public enum GetPasswordQualityRequirementsTargetType
066{
067  /**
068   * Indicates that the Directory Server should return the password quality
069   * requirements that the server's default password policy will impose for an
070   * add operation.
071   */
072  ADD_WITH_DEFAULT_PASSWORD_POLICY((byte) 0x80),
073
074
075
076  /**
077   * Indicates that the Directory Server should return the password quality
078   * requirements that the server will impose for an add operation for an entry
079   * governed by a specific password policy.  The password policy will be
080   * identified by the DN of the entry containing the password policy
081   * definition.
082   */
083  ADD_WITH_SPECIFIED_PASSWORD_POLICY((byte) 0x81),
084
085
086
087  /**
088   * Indicates that the Directory Server should return the password quality
089   * requirements that the server will impose for a self password change for
090   * the authorization identity used for the get password quality requirements
091   * extended request.
092   */
093  SELF_CHANGE_FOR_AUTHORIZATION_IDENTITY((byte) 0x82),
094
095
096
097  /**
098   * Indicates that the Directory Server should return the password quality
099   * requirements that the server will impose for a self password change for a
100   * specific user, identified by DN.
101   */
102  SELF_CHANGE_FOR_SPECIFIED_USER((byte) 0x83),
103
104
105
106  /**
107   * Indicates that the Directory Server should return the password quality
108   * requirements that the server will impose for an administrative password
109   * reset for a specific user, identified by DN.
110   */
111  ADMINISTRATIVE_RESET_FOR_SPECIFIED_USER((byte) 0x84);
112
113
114
115  // The BER type that will be used for this target type in an encoded get
116  // password quality requirements extended request.
117  private final byte berType;
118
119
120
121  /**
122   * Creates a new get password quality requirements target type with the
123   * specified BER type.
124   *
125   * @param  berType  The BER type that will be used for this target type in an
126   *                  encoded get password quality requirements extended
127   *                  request.
128   */
129  GetPasswordQualityRequirementsTargetType(final byte berType)
130  {
131    this.berType = berType;
132  }
133
134
135
136  /**
137   * Retrieves the BER type that will be used for this target type in an encoded
138   * get password quality requirements extended request.
139   *
140   * @return  The BER type that will be used for this target type in an encoded
141   *          get password quality requirements extended request.
142   */
143  public byte getBERType()
144  {
145    return berType;
146  }
147
148
149
150  /**
151   * Retrieves the get password quality requirements target type with the
152   * specified BER type.
153   *
154   * @param  berType  The BER type for the target type to retrieve.
155   *
156   * @return  The get password quality requirements target type with the
157   *          specified BER type, or {@code null} if there is no target type
158   *          with the specified BER type.
159   */
160  @Nullable()
161  public static GetPasswordQualityRequirementsTargetType forBERType(
162                     final byte berType)
163  {
164    for (final GetPasswordQualityRequirementsTargetType t : values())
165    {
166      if (t.berType == berType)
167      {
168        return t;
169      }
170    }
171
172    return null;
173  }
174
175
176
177  /**
178   * Retrieves the get password quality requirements target type with the
179   * specified name.
180   *
181   * @param  name  The name of the get password quality requirements target type
182   *               to retrieve.  It must not be {@code null}.
183   *
184   * @return  The requested get password quality requirements target type, or
185   *          {@code null} if no such type is defined.
186   */
187  @Nullable()
188  public static GetPasswordQualityRequirementsTargetType forName(
189                     @NotNull final String name)
190  {
191    switch (StaticUtils.toLowerCase(name))
192    {
193      case "addwithdefaultpasswordpolicy":
194      case "add-with-default-password-policy":
195      case "add_with_default_password_policy":
196        return ADD_WITH_DEFAULT_PASSWORD_POLICY;
197      case "addwithspecifiedpasswordpolicy":
198      case "add-with-specified-password-policy":
199      case "add_with_specified_password_policy":
200        return ADD_WITH_SPECIFIED_PASSWORD_POLICY;
201      case "selfchangeforauthorizationidentity":
202      case "self-change-for-authorization-identity":
203      case "self_change_for_authorization_identity":
204        return SELF_CHANGE_FOR_AUTHORIZATION_IDENTITY;
205      case "selfchangeforspecifieduser":
206      case "self-change-for-specified-user":
207      case "self_change_for_specified_user":
208        return SELF_CHANGE_FOR_SPECIFIED_USER;
209      case "administrativeresetforspecifieduser":
210      case "administrative-reset-for-specified-user":
211      case "administrative_reset_for_specified_user":
212        return ADMINISTRATIVE_RESET_FOR_SPECIFIED_USER;
213      default:
214        return null;
215    }
216  }
217}