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