001/*
002 * Copyright 2017-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2017-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.util.ssl.cert;
022
023
024
025import com.unboundid.util.ThreadSafety;
026import com.unboundid.util.ThreadSafetyLevel;
027
028
029
030/**
031 * This enum defines a set of supported RSA private key versions.
032 */
033@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
034public enum RSAPrivateKeyVersion
035{
036  /**
037   * The two-prime RSA private key version.
038   */
039  TWO_PRIME(0, "two-prime"),
040
041
042
043  /**
044   * The multi RSA private key version.
045   */
046  MULTI(1, "multi");
047
048
049
050  // The integer value for this RSA private key version.
051  private final int intValue;
052
053  // The name for this RSA private key version.
054  private final String name;
055
056
057
058  /**
059   * Creates a new RSA private key version with the provided information.
060   *
061   * @param  intValue  The integer value for the private key version.
062   * @param  name      The name for this private key version.  It must not be
063   *                   {@code null}.
064   */
065  RSAPrivateKeyVersion(final int intValue, final String name)
066  {
067    this.intValue = intValue;
068    this.name = name;
069  }
070
071
072
073  /**
074   * Retrieves the integer value for this private key version.
075   *
076   * @return  The integer value for this private key version.
077   */
078  int getIntValue()
079  {
080    return intValue;
081  }
082
083
084
085  /**
086   * Retrieves the name for this private key version.
087   *
088   * @return  The name for this private key version.
089   */
090  public String getName()
091  {
092    return name;
093  }
094
095
096
097  /**
098   * Retrieves the private key version for the provided integer value.
099   *
100   * @param  intValue  The integer value for the private key version to
101   *                   retrieve.
102   *
103   * @return  The private key version for the provided integer value, or
104   *          {@code null} if the provided version does not correspond to any
105   *          known private key version value.
106   */
107  static RSAPrivateKeyVersion valueOf(final int intValue)
108  {
109    for (final RSAPrivateKeyVersion v : values())
110    {
111      if (v.intValue == intValue)
112      {
113        return v;
114      }
115    }
116
117    return null;
118  }
119}