|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.vt.middleware.crypt.util.PemHelper
public class PemHelper
Helper class provides operations for encoding/decoding cryptographic keys and certificates to PEM format.
| Field Summary | |
|---|---|
static String |
DEK_INFO
Decryption infor tag for PEM-encoded private key in OpenSSL format. |
static String |
FOOTER_END
PEM encoding footer start string. |
static String |
HEADER_BEGIN
PEM encoding header start string. |
static String |
KEY_ENCRYPTION_ALGORITHM
Encryption algorithm used for password-protected private keys. |
static String |
PROC_TYPE
Procedure type tag for PEM-encoded private key in OpenSSL format. |
| Constructor Summary | |
|---|---|
protected |
PemHelper()
Hidden constructor of utility class. |
| Method Summary | |
|---|---|
static byte[] |
decode(byte[] pem)
Decodes a PEM-encoded cryptographic object into the raw bytes of its ASN.1 encoding. |
static byte[] |
decode(String pem)
Decodes a PEM-encoded cryptographic object into the raw bytes of its ASN.1 encoding. |
static Certificate |
decodeCert(String pemCert)
Decodes the given certificate from PEM format. |
static PublicKey |
decodeKey(String pemKey)
Decodes the given public key from PEM format. |
static PrivateKey |
decodeKey(String pemKey,
char[] password)
Decodes the given private key from PEM format. |
static String |
encodeCert(Certificate key)
Encodes the given certificate to PEM format. |
static String |
encodeKey(PrivateKey key,
char[] password,
SecureRandom random)
Encodes the given private key to PEM format. |
static String |
encodeKey(PublicKey key)
Encodes the given public key to PEM format. |
static boolean |
isBase64Char(byte b)
Determines whether the given byte represents an ASCII character in the character set for base64 encoding. |
static boolean |
isPem(byte[] data)
Determines whether the data in the given byte array is base64-encoded data of PEM encoding. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String KEY_ENCRYPTION_ALGORITHM
public static final String HEADER_BEGIN
public static final String FOOTER_END
public static final String PROC_TYPE
public static final String DEK_INFO
| Constructor Detail |
|---|
protected PemHelper()
| Method Detail |
|---|
public static byte[] decode(byte[] pem)
throws IOException
pem - Bytes of PEM-encoded data to decode.
IOException - On decoding error.
public static byte[] decode(String pem)
throws IOException
pem - PEM-encoded data to decode.
IOException - On decoding error.
public static String encodeKey(PublicKey key)
throws IOException
key - Public key to encode.
IOException - On encoding error.
public static PublicKey decodeKey(String pemKey)
throws IOException
pemKey - PEM-encoded public key text to decode.
IOException - On decoding error.
public static String encodeKey(PrivateKey key,
char[] password,
SecureRandom random)
throws IOException
key - Private key to encode.password - Password used to encrypt private key using 256-bit AES
encryption; may be null to indicate no encryption.random - Secure random provider used for encrypting private key.
IOException - On encoding error.
public static PrivateKey decodeKey(String pemKey,
char[] password)
throws IOException
pemKey - PEM-encoded private key text to decode.password - Optional password that is used to decrypt private key
using DESEDE algorithm when specified.
IOException - On decoding error.
public static String encodeCert(Certificate key)
throws IOException
key - Certificate to encode.
IOException - On encoding error.
public static Certificate decodeCert(String pemCert)
throws IOException
pemCert - PEM-encoded certificate text to decode.
IOException - On decoding error.public static boolean isPem(byte[] data)
data - Data to test for PEM encoding
public static boolean isBase64Char(byte b)
b - Byte to test.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||