|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pk.edu.niit.clarens.util.PEMBlock
This class represents an arbitrary block of PEM encoded data. The
getInstance(java.lang.String)
method is used to create a type specific instance
representing the actual PEM block type. PEM block types include
PKCS8 private keys and PEM encoded certificates.
Field Summary | |
protected java.lang.String |
base64BlockData
|
protected java.security.cert.Certificate |
certificate
|
protected byte[] |
derBlockData
|
protected java.lang.String |
footer
|
protected java.lang.String |
header
|
static int |
PEM_CERTIFICATE
A PEM-encoded certificate. |
static int |
PEM_OPENSSL_DSA
An openssl traditional format private DSA key. |
static int |
PEM_OPENSSL_RSA
An openssl traditional format private RSA key. |
static int |
PEM_PKCS8_ENCRYPTED
A PKCS#8 encrypted private key. |
static int |
PEM_PKCS8_UNENCRYPTED
A PKCS#8 unencrypted private key. |
static int |
PEM_UNKNOWN
An unknown PEM-encoded block. |
protected java.lang.String |
PEMdata
|
protected java.security.PrivateKey |
privateKey
|
protected int |
type
|
protected java.lang.String |
typeString
|
Method Summary | |
abstract java.security.cert.Certificate |
getCertificate()
Get the certificate represented by this block. |
static PEMBlock |
getInstance(java.io.BufferedReader data)
Load a PEM-encoded certificate or key block from an input reader. |
static PEMBlock |
getInstance(java.lang.String data)
Load a PEM-encoded certificate or key block from a string. |
java.lang.String |
getPem()
Get the PEM data as a string. |
abstract java.security.PrivateKey |
getPrivateKey()
Get the unencrypted private key structure represented by this block. |
abstract java.security.PrivateKey |
getPrivateKey(java.lang.String passphrase)
Get the encrypted private key structure represented by this block. |
int |
getType()
Get the type of block. |
java.lang.String |
getTypeString()
Get a string description of this block type. |
protected void |
load(java.lang.String s)
Decode a PEM encoded block into more usable data. |
protected static java.lang.String |
ReadBeginEnd(java.io.BufferedReader inputReader)
Returns the text between -----BEGIN XXXX----- and -----END XXXX----- read from the provided inputReader. |
protected static java.lang.String |
ReadBeginEnd(java.lang.String inputString)
Returns the text between -----BEGIN XXXX----- and -----END XXXX----- read from the provided string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PEM_UNKNOWN
public static final int PEM_PKCS8_UNENCRYPTED
public static final int PEM_PKCS8_ENCRYPTED
public static final int PEM_OPENSSL_RSA
public static final int PEM_OPENSSL_DSA
public static final int PEM_CERTIFICATE
protected java.lang.String header
protected java.lang.String footer
protected java.lang.String base64BlockData
protected java.lang.String PEMdata
protected byte[] derBlockData
protected int type
protected java.lang.String typeString
protected java.security.PrivateKey privateKey
protected java.security.cert.Certificate certificate
Method Detail |
public static PEMBlock getInstance(java.lang.String data) throws java.security.cert.CertificateException, java.io.IOException
CertificateBlock
.
data
- The string containing the PEM-encoded certificate or key.
java.io.IOException
- Thrown if there was a problem decoding the base64
PEM data.
java.security.cert.CertificateException
- Thrown if a valid PEM block could not be
found. This may occur if no BEGIN line is found, or no matching
END line is found.public static PEMBlock getInstance(java.io.BufferedReader data) throws java.io.IOException, java.security.cert.CertificateException
data
- The string containing the PEM-encoded certificate or key.
java.io.IOException
- Thrown if there was a problem decoding the base64
PEM data.
java.security.cert.CertificateException
- Thrown if a valid PEM block could not be
found. This may occur if no BEGIN line is found, or no matching
END line is found.protected void load(java.lang.String s) throws java.security.cert.CertificateException, java.io.IOException
s
- The string containing the PEM encoded data.
java.security.cert.CertificateException
- Thrown if there was a problem in the
PEM structure.
java.io.IOException
- Thrown if there was a problem decoding the base64
data.public java.lang.String getPem()
public int getType()
PEM_UNKNOWN
is returned if nothing has been loaded or if
the block type could not be determined.public java.lang.String getTypeString()
public abstract java.security.PrivateKey getPrivateKey() throws java.security.cert.CertificateException
java.security.cert.CertificateException
- Thrown if there was a problem extracting
the private key from the block data. This can occur if the private
key format is unsupported (openssl DSA) or if the private key
was encrypted.public abstract java.security.PrivateKey getPrivateKey(java.lang.String passphrase) throws java.security.cert.CertificateException
java.security.cert.CertificateException
- Thrown if there was a problem extracting
the private key from the block data.public abstract java.security.cert.Certificate getCertificate()
protected static java.lang.String ReadBeginEnd(java.io.BufferedReader inputReader) throws java.io.IOException
inputReader
- A Reader connected to the source of the input.
java.io.IOException
- Thrown if there was a problem reading from the
input source.protected static java.lang.String ReadBeginEnd(java.lang.String inputString) throws java.io.IOException
inputString
- The string containing the block of text.
java.io.IOException
- Thrown if there was a problem reading from the
input source.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |