001/*
002 * Copyright 2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2019 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.ThreadSafety;
026import com.unboundid.util.ThreadSafetyLevel;
027
028
029
030/**
031 * This enum describes the mechanism that the server should use when selecting
032 * the password policy to use (for its password generator and validators) while
033 * processing a {@link GeneratePasswordExtendedRequest}.
034 * <BR>
035 * <BLOCKQUOTE>
036 *   <B>NOTE:</B>  This class, and other classes within the
037 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
038 *   supported for use against Ping Identity, UnboundID, and
039 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
040 *   for proprietary functionality or for external specifications that are not
041 *   considered stable or mature enough to be guaranteed to work in an
042 *   interoperable way with other types of LDAP servers.
043 * </BLOCKQUOTE>
044 */
045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
046public enum GeneratePasswordPolicySelectionType
047{
048  /**
049   * The selection type that indicates that the server should use the default
050   * password policy as defined in the configuration.
051   */
052  DEFAULT_POLICY((byte) 0x80),
053
054
055
056  /**
057   * The selection type that indicates that the server should use the password
058   * policy that is defined in a specified entry.
059   */
060  PASSWORD_POLICY_DN((byte) 0x81),
061
062
063
064  /**
065   * The selection type that indicates that the server should use the password
066   * policy that governs a specified entry.
067   */
068  TARGET_ENTRY_DN((byte) 0x82);
069
070
071
072  // The BER type associated with this password policy selection type.
073  private final byte berType;
074
075
076
077  /**
078   * Creates a new password policy selection type with the provided BER type.
079   *
080   * @param  type  The BER type associated with this password policy selection
081   *               type.
082   */
083  GeneratePasswordPolicySelectionType(final byte type)
084  {
085    this.berType = type;
086  }
087
088
089
090  /**
091   * Retrieves the BER type that will be used to identify this password policy
092   * selection type in a {@link GeneratePasswordExtendedRequest}.
093   *
094   * @return  The BER type that will be used to identify this password policy
095   *          selection type in a generate password extended request.
096   */
097  public byte getBERType()
098  {
099    return berType;
100  }
101
102
103
104  /**
105   * Retrieves the password policy selection type with the specified BER type.
106   *
107   * @param  berType  The BER type for the password policy selection type to
108   *                  retrieve.
109   *
110   * @return  The password policy selection type with the specified BER type,
111   *          or {@code null} if there is no selection type with the provided
112   *          BER type.
113   */
114  public static GeneratePasswordPolicySelectionType forType(final byte berType)
115  {
116    for (final GeneratePasswordPolicySelectionType t : values())
117    {
118      if (t.berType == berType)
119      {
120        return t;
121      }
122    }
123
124    return null;
125  }
126}