com.amazonaws.auth
Enum PEM

java.lang.Object
  extended by java.lang.Enum<PEM>
      extended by com.amazonaws.auth.PEM
All Implemented Interfaces:
Serializable, Comparable<PEM>

public enum PEM
extends Enum<PEM>

A PEM utility that can be used to read keys from PEM. With this PEM utility, private keys in either PKCS#1 or PKCS#8 PEM encoded format can be read without the need to depend on the Bouncy Castle library.

Some background information:


Method Summary
static List<PEMObject> readPEMObjects(InputStream is)
          A lower level API used to returns all PEM objects that can be read off from the input stream of a PEM file.
static PrivateKey readPrivateKey(InputStream is)
          Returns the first private key that is found from the input stream of a PEM file.
static PublicKey readPublicKey(InputStream is)
          Returns the first public key that is found from the input stream of a PEM file.
static PEM valueOf(String name)
          Returns the enum constant of this type with the specified name.
static PEM[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

values

public static PEM[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (PEM c : PEM.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static PEM valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

readPrivateKey

public static PrivateKey readPrivateKey(InputStream is)
                                 throws InvalidKeySpecException,
                                        IOException
Returns the first private key that is found from the input stream of a PEM file.

Throws:
InvalidKeySpecException - if failed to convert the DER bytes into a private key.
IllegalArgumentException - if no private key is found.
IOException

readPublicKey

public static PublicKey readPublicKey(InputStream is)
                               throws InvalidKeySpecException,
                                      IOException
Returns the first public key that is found from the input stream of a PEM file.

Throws:
InvalidKeySpecException - if failed to convert the DER bytes into a public key.
IllegalArgumentException - if no public key is found.
IOException

readPEMObjects

public static List<PEMObject> readPEMObjects(InputStream is)
                                      throws IOException
A lower level API used to returns all PEM objects that can be read off from the input stream of a PEM file.

This method can be useful if more than one PEM object of different types are embedded in the same PEM file.

Throws:
IOException


Copyright © 2016. All rights reserved.