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