java.lang.Object
edu.iu.crypt.PemEncoded
Reads PEM-encoded key and/or certificate data.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionGets the certificate whenkeyType
isPemEncoded.KeyType.CERTIFICATE
.static X509Certificate
asCertificate
(byte[] encoded) Parses raw data asX509Certificate
asCRL()
Gets the certificate whenkeyType
isPemEncoded.KeyType.CERTIFICATE
.static X509CRL
asCRL
(byte[] encoded) Parses raw data asX509CRL
Gets the key as a private key whenkeyType
isPemEncoded.KeyType.PRIVATE_KEY
.Gets the key as a public key whenkeyType
isPemEncoded.KeyType.PUBLIC_KEY
.static X509Certificate[]
getCertificateChain
(URI uri) Reads a certificate chain from a URI.static X509Certificate[]
Converts parsed PEM data to a certificate chain.Gets the key type.static Iterator
<PemEncoded> parse
(InputStream in) Reads PEM-encoded key and/or certificate data.static Iterator
<PemEncoded> Parses PEM-encoded key and/or certificate data.static Iterator
<PemEncoded> serialize
(X509Certificate... cert) Serializes an X509 certificate chain as PEM encoded.static Iterator
<PemEncoded> serialize
(KeyPair keyPair, X509Certificate... cert) Checks that public and private key, and certificate chain, are related and converts to PEM encoded form.toString()
-
Method Details
-
parse
Reads PEM-encoded key and/or certificate data.- Parameters:
in
- input stream of PEM-encoded key and/or certificate data, multiple entries may be concatenated- Returns:
- Parsed PEM-encoded data
- See Also:
-
parse
Parses PEM-encoded key and/or certificate data.- Parameters:
pemEncoded
- PEM-encoded key and/or certificate data, may be concatenated- Returns:
- Parsed PEM-encoded data
- See Also:
-
serialize
Serializes an X509 certificate chain as PEM encoded.- Parameters:
cert
- certificate chain- Returns:
- PEM encoded certificate data
-
serialize
Checks that public and private key, and certificate chain, are related and converts to PEM encoded form.Public key will be omitted if it matches the first certificate in the chain, or if it is fully encoded as a subset of the private key.
- Parameters:
keyPair
- public and optional private key to exportcert
- certificate chain- Returns:
- PEM encoded key data
-
getCertificateChain
Converts parsed PEM data to a certificate chain.- Parameters:
pem
- PEM encoded certificate chain- Returns:
- certificate chain
-
getCertificateChain
Reads a certificate chain from a URI.- Parameters:
uri
-URI
- Returns:
- certificate chain
- See Also:
-
asCertificate
Parses raw data asX509Certificate
- Parameters:
encoded
- DER encoded X.509 certificate data- Returns:
X509Certificate
-
asCRL
Parses raw data asX509CRL
- Parameters:
encoded
- DER encoded X.509 CLR data- Returns:
X509CRL
-
getKeyType
Gets the key type.- Returns:
PemEncoded.KeyType
-
asPublic
Gets the key as a public key whenkeyType
isPemEncoded.KeyType.PUBLIC_KEY
.- Parameters:
algorithm
-KeyFactory
algorithm- Returns:
- public key
-
asPrivate
Gets the key as a private key whenkeyType
isPemEncoded.KeyType.PRIVATE_KEY
.- Parameters:
algorithm
-KeyFactory
algorithm- Returns:
- private key
-
asCertificate
Gets the certificate whenkeyType
isPemEncoded.KeyType.CERTIFICATE
.- Returns:
- private key
-
asCRL
Gets the certificate whenkeyType
isPemEncoded.KeyType.CERTIFICATE
.- Returns:
- private key
-
toString
-