001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027package org.opends.server.types;
028
029
030
031/**
032 * This enumeration defines the set of possible authentication types
033 * that may be used for a bind request.  This is based on the LDAP
034 * specification defined in RFC 2251.
035 */
036@org.opends.server.types.PublicAPI(
037     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
038     mayInstantiate=false,
039     mayExtend=false,
040     mayInvoke=true)
041public enum AuthenticationType
042{
043  /**
044   * The authentication type that indicates that the user will be
045   * performing simple authentication (i.e., just a password).
046   */
047  SIMPLE((byte) 0x80),
048
049
050
051  /**
052   * The authentication type that indicates that the user will be
053   * performing SASL authentication using some extensible mechanism.
054   */
055  SASL((byte) 0xA3),
056
057
058
059  /**
060   * The authentication type that indicates that the associated
061   * connection is an internal connection.
062   */
063  INTERNAL((byte) 0xFF);
064
065
066
067  /** The BER type tag that is associated with this authentication type. */
068  private byte berType;
069
070
071
072  /**
073   * Creates a new authentication type with the provided BER type tag.
074   *
075   * @param  berType  The BER type tag that is associated with this
076   *                  authentication type.
077   */
078  private AuthenticationType(byte berType)
079  {
080    this.berType = berType;
081  }
082
083
084
085  /**
086   * Retrieves the BER type tag associated with this authentication
087   * type.
088   *
089   * @return  The BER type tag associated with this authentication
090   *          type.
091   */
092  public int getBERType()
093  {
094    return berType;
095  }
096
097
098
099  /**
100   * Retrieves a string representation of this authentication type.
101   *
102   * @return  A string representation of this authentication type.
103   */
104  public String toString()
105  {
106    switch (berType)
107    {
108      case (byte) 0x80:
109        return "Simple";
110      case (byte) 0xA3:
111        return "SASL";
112      case (byte) 0xFF:
113        return "Internal";
114      default:
115        return "Unknown";
116    }
117  }
118}
119