iaik.me.utils
Class PEM

java.lang.Object
  |
  +--iaik.me.utils.PEM

public class PEM
extends Object

Utility class to handle the ASCII compatible PEM format.


Field Summary
static String PEM_ID_CERTIFICATE
          ID used for PEM encoded X.509 certificates.
static String PEM_ID_CERTIFICATE_REQUEST
          ID used for PEM encoded certificate requests.
static String PEM_ID_ENCRYPTED_KEY
          ID used for PEM encoded PKCS#8 encrypted private keys.
 
Constructor Summary
PEM(InputStream in)
          Create a PEM object from an InputStream.
PEM(Reader reader)
          Create a PEM object from a Reader.
 
Method Summary
 byte[] nextData()
          Get the next PEM part.
 InputStream nextInputStream()
          Get the next PEM part as a InputStream.
static byte[] toPEM(byte[] data, String id)
          Convert the data to PEM format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PEM_ID_CERTIFICATE

public static final String PEM_ID_CERTIFICATE
ID used for PEM encoded X.509 certificates.

PEM_ID_CERTIFICATE_REQUEST

public static final String PEM_ID_CERTIFICATE_REQUEST
ID used for PEM encoded certificate requests.

PEM_ID_ENCRYPTED_KEY

public static final String PEM_ID_ENCRYPTED_KEY
ID used for PEM encoded PKCS#8 encrypted private keys.
Constructor Detail

PEM

public PEM(InputStream in)
    throws IOException
Create a PEM object from an InputStream.

PEM

public PEM(Reader reader)
    throws IOException
Create a PEM object from a Reader.
Method Detail

nextData

public byte[] nextData()
                throws IOException
Get the next PEM part. It returns the base64 decoded data between the next BEGIN and END lines.

nextInputStream

public InputStream nextInputStream()
                            throws IOException
Get the next PEM part as a InputStream.

toPEM

public static byte[] toPEM(byte[] data,
                           String id)
Convert the data to PEM format. Id should be one of the String constants defined in this class and data should be the DER encoding of an object of this type.

Example: PEM.toPEM(cert.getEncoded(), PEM.PEM_ID_CERTIFICATE);


This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note).

IAIK-JCE ME 3.04, (c) 2002 IAIK, (c) 2003 to 2006 Stiftung SIC