Package org.jclouds.crypto
Class Pems
java.lang.Object
org.jclouds.crypto.Pems
Reads and writes PEM encoded Strings and Streams
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
fromPem
(com.google.common.io.ByteSource supplier, org.jclouds.crypto.Pems.PemProcessor<T> processor) Returns the object of generic typeT
that is pem encoded in the supplier.static String
pem
(X509Certificate cert) encodes theX509Certificate
to PEM format.static String
pem
(PrivateKey key) encodes thePrivateKey
to PEM format.static String
encodes thePublicKey
to PEM format.static KeySpec
privateKeySpec
(com.google.common.io.ByteSource supplier) Returns theinvalid reference
RSAPrivateKeySpec
static KeySpec
privateKeySpec
(String pem) ExecutesprivateKeySpec(ByteSource)
on the string which contains an encoded private key in PEM format.static KeySpec
publicKeySpec
(com.google.common.io.ByteSource supplier) Returns theKeySpec
that is pem encoded in the supplier.static KeySpec
publicKeySpec
(String pem) ExecutespublicKeySpec(ByteSource)
on the string which contains an encoded public key in PEM format.static X509Certificate
x509Certificate
(com.google.common.io.ByteSource supplier, CertificateFactory certFactory) Returns theX509EncodedKeySpec
that is pem encoded in the supplier.static X509Certificate
x509Certificate
(String pem) Executesx509Certificate(ByteSource, CertificateFactory)
on the string which contains an X.509 certificate in PEM format.
-
Field Details
-
PRIVATE_PKCS1_MARKER
- See Also:
-
PRIVATE_PKCS8_MARKER
- See Also:
-
CERTIFICATE_X509_MARKER
- See Also:
-
PUBLIC_X509_MARKER
- See Also:
-
PUBLIC_PKCS1_MARKER
- See Also:
-
PROC_TYPE_ENCRYPTED
- See Also:
-
-
Constructor Details
-
Pems
public Pems()
-
-
Method Details
-
fromPem
public static <T> T fromPem(com.google.common.io.ByteSource supplier, org.jclouds.crypto.Pems.PemProcessor<T> processor) throws IOException Returns the object of generic typeT
that is pem encoded in the supplier.- Parameters:
supplier
- the input stream factoryprocessor
- how to parser the object from a byte arraymarker
- header that begins the PEM block- Returns:
- the object of generic type
T
which was PEM encoded in the stream - Throws:
IOException
- if an I/O error occurs
-
privateKeySpec
Returns theinvalid reference
RSAPrivateKeySpec
- Parameters:
supplier
- the input stream factory- Returns:
- the
invalid reference
RSAPrivateKeySpec
- Throws:
IOException
- if an I/O error occurs
-
privateKeySpec
ExecutesprivateKeySpec(ByteSource)
on the string which contains an encoded private key in PEM format.- Parameters:
pem
- private key in pem encoded format.- See Also:
-
publicKeySpec
Returns theKeySpec
that is pem encoded in the supplier.- Parameters:
supplier
- the input stream factory- Returns:
- the
KeySpec
which was PEM encoded in the stream - Throws:
IOException
- if an I/O error occurs
-
publicKeySpec
ExecutespublicKeySpec(ByteSource)
on the string which contains an encoded public key in PEM format.- Parameters:
pem
- public key in pem encoded format.- Throws:
IOException
- See Also:
-
x509Certificate
public static X509Certificate x509Certificate(com.google.common.io.ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException Returns theX509EncodedKeySpec
that is pem encoded in the supplier.- Parameters:
supplier
- the input stream factorycertFactory
- or null to use default- Returns:
- the
X509EncodedKeySpec
which was PEM encoded in the stream - Throws:
IOException
- if an I/O error occursCertificateException
-
x509Certificate
Executesx509Certificate(ByteSource, CertificateFactory)
on the string which contains an X.509 certificate in PEM format.- Parameters:
pem
- certificate in pem encoded format.- Throws:
IOException
CertificateException
- See Also:
-
pem
encodes theX509Certificate
to PEM format.- Parameters:
cert
- what to encode- Returns:
- the PEM encoded certificate
- Throws:
IOException
CertificateEncodingException
-
pem
encodes thePublicKey
to PEM format. -
pem
encodes thePrivateKey
to PEM format.
-