001/*
002 * Copyright 2015-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds.extensions;
022
023
024
025import com.unboundid.util.StaticUtils;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This enum specifies the modes in which the get password quality requirements
033 * extended operation may determine the type of password update operation that
034 * will be performed and the way in which the server should determine which
035 * password policy to use in order to obtain the password quality requirements.
036 * <BR>
037 * <BLOCKQUOTE>
038 *   <B>NOTE:</B>  This class, and other classes within the
039 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
040 *   supported for use against Ping Identity, UnboundID, and
041 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
042 *   for proprietary functionality or for external specifications that are not
043 *   considered stable or mature enough to be guaranteed to work in an
044 *   interoperable way with other types of LDAP servers.
045 * </BLOCKQUOTE>
046 */
047@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
048public enum GetPasswordQualityRequirementsTargetType
049{
050  /**
051   * Indicates that the Directory Server should return the password quality
052   * requirements that the server's default password policy will impose for an
053   * add operation.
054   */
055  ADD_WITH_DEFAULT_PASSWORD_POLICY((byte) 0x80),
056
057
058
059  /**
060   * Indicates that the Directory Server should return the password quality
061   * requirements that the server will impose for an add operation for an entry
062   * governed by a specific password policy.  The password policy will be
063   * identified by the DN of the entry containing the password policy
064   * definition.
065   */
066  ADD_WITH_SPECIFIED_PASSWORD_POLICY((byte) 0x81),
067
068
069
070  /**
071   * Indicates that the Directory Server should return the password quality
072   * requirements that the server will impose for a self password change for
073   * the authorization identity used for the get password quality requirements
074   * extended request.
075   */
076  SELF_CHANGE_FOR_AUTHORIZATION_IDENTITY((byte) 0x82),
077
078
079
080  /**
081   * Indicates that the Directory Server should return the password quality
082   * requirements that the server will impose for a self password change for a
083   * specific user, identified by DN.
084   */
085  SELF_CHANGE_FOR_SPECIFIED_USER((byte) 0x83),
086
087
088
089  /**
090   * Indicates that the Directory Server should return the password quality
091   * requirements that the server will impose for an administrative password
092   * reset for a specific user, identified by DN.
093   */
094  ADMINISTRATIVE_RESET_FOR_SPECIFIED_USER((byte) 0x84);
095
096
097
098  // The BER type that will be used for this target type in an encoded get
099  // password quality requirements extended request.
100  private final byte berType;
101
102
103
104  /**
105   * Creates a new get password quality requirements target type with the
106   * specified BER type.
107   *
108   * @param  berType  The BER type that will be used for this target type in an
109   *                  encoded get password quality requirements extended
110   *                  request.
111   */
112  GetPasswordQualityRequirementsTargetType(final byte berType)
113  {
114    this.berType = berType;
115  }
116
117
118
119  /**
120   * Retrieves the BER type that will be used for this target type in an encoded
121   * get password quality requirements extended request.
122   *
123   * @return  The BER type that will be used for this target type in an encoded
124   *          get password quality requirements extended request.
125   */
126  public byte getBERType()
127  {
128    return berType;
129  }
130
131
132
133  /**
134   * Retrieves the get password quality requirements target type with the
135   * specified BER type.
136   *
137   * @param  berType  The BER type for the target type to retrieve.
138   *
139   * @return  The get password quality requirements target type with the
140   *          specified BER type, or {@code null} if there is no target type
141   *          with the specified BER type.
142   */
143  public static GetPasswordQualityRequirementsTargetType forBERType(
144                     final byte berType)
145  {
146    for (final GetPasswordQualityRequirementsTargetType t : values())
147    {
148      if (t.berType == berType)
149      {
150        return t;
151      }
152    }
153
154    return null;
155  }
156
157
158
159  /**
160   * Retrieves the get password quality requirements target type with the
161   * specified name.
162   *
163   * @param  name  The name of the get password quality requirements target type
164   *               to retrieve.  It must not be {@code null}.
165   *
166   * @return  The requested get password quality requirements target type, or
167   *          {@code null} if no such type is defined.
168   */
169  public static GetPasswordQualityRequirementsTargetType forName(
170                                                              final String name)
171  {
172    switch (StaticUtils.toLowerCase(name))
173    {
174      case "addwithdefaultpasswordpolicy":
175      case "add-with-default-password-policy":
176      case "add_with_default_password_policy":
177        return ADD_WITH_DEFAULT_PASSWORD_POLICY;
178      case "addwithspecifiedpasswordpolicy":
179      case "add-with-specified-password-policy":
180      case "add_with_specified_password_policy":
181        return ADD_WITH_SPECIFIED_PASSWORD_POLICY;
182      case "selfchangeforauthorizationidentity":
183      case "self-change-for-authorization-identity":
184      case "self_change_for_authorization_identity":
185        return SELF_CHANGE_FOR_AUTHORIZATION_IDENTITY;
186      case "selfchangeforspecifieduser":
187      case "self-change-for-specified-user":
188      case "self_change_for_specified_user":
189        return SELF_CHANGE_FOR_SPECIFIED_USER;
190      case "administrativeresetforspecifieduser":
191      case "administrative-reset-for-specified-user":
192      case "administrative_reset_for_specified_user":
193        return ADMINISTRATIVE_RESET_FOR_SPECIFIED_USER;
194      default:
195        return null;
196    }
197  }
198}