com.novell.zos.tls
Class PemCertificate

java.lang.Object
  extended by com.novell.zos.tls.PemCertificate

public class PemCertificate
extends Object

PEM Certificate wrapper for X.509 certificates.

This convenience class wraps up an X.509 certificate in an object that allows the certificate to be read from and stored to a standard PEM encoded X.509 certificate file. This allows the ZOS client to make use of the Sun TLS provider without requiring that the ZOS server certificate be manually installed in the JRE's keystore. The use of standardized PEM certificates allows more portable handling and offline generation of certificates, if desired for security purposes, and enables simplified management of certificates.

Since:
ZOS 1.3

Constructor Summary
PemCertificate()
           
 
Method Summary
static PemCertificate convert(X509Certificate cert)
          Convert an existing X509Certificate instance to PEM.
 X509Certificate getCertificate()
          Return the X509Certificate contained by this instance.
 String getPemCertificate()
          Return the certificate as a PEM encoded string.
 PublicKey getPublicKey()
          Return the PublicKey contained by this instance.
static PemCertificate load(String filename)
          Load a PEM certificate from a file.
 void store(String filename)
          Store a certificate in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PemCertificate

public PemCertificate()
Method Detail

convert

public static PemCertificate convert(X509Certificate cert)
                              throws CertificateException
Convert an existing X509Certificate instance to PEM.

Converts an existing X509Certificate to an instance of PemCertificate that may be used to read and write the certificate in PEM encoded format.

Parameters:
cert - The X509Certificate to convert.
Returns:
The PemCertificate containing the newly encoded certificate.
Throws:
CertificateException - Thrown if cert cannot be encoded into PEM format.

load

public static PemCertificate load(String filename)
                           throws IOException,
                                  CertificateException
Load a PEM certificate from a file.

Reads a PEM encoded X.509 certificate from the file specified by filename. The certificate is decoded and stored inside a new instance of PemCertificate.

Parameters:
filename - The name of the file from which to read the PEM encoded certificate.
Returns:
The decoded certificate as a PemCertificate instance.
Throws:
IOException - If an I/O error prevents reading the file.
CertificateException - If contents of filename cannot be decoded as a certificate.

store

public void store(String filename)
           throws IOException
Store a certificate in a file.

Stores the certificate contained by this instance as a PEM encoded file specified by filename.

Parameters:
filename - The name of the file in which to store the PEM encoded certificate.
Throws:
IOException - Thrown if an I/O error prevents writing to filename.

getCertificate

public X509Certificate getCertificate()
Return the X509Certificate contained by this instance.

Returns the X509Certificate instance contained by this PemCertificate. The returned certificate object may be passed to standard Java security APIs such as Sun's TLS/SSL provider.

Returns:
The X509Certificate contained by this instance.

getPublicKey

public PublicKey getPublicKey()
Return the PublicKey contained by this instance.

Returns the PublicKey of the X509Certificate instance contained by this PemCertificate. The returned public key object may be passed to standard Java security APIs such as Sun's TLS/SSL provider.

Returns:
The PublicKey contained by this instance.

getPemCertificate

public String getPemCertificate()
Return the certificate as a PEM encoded string.

Returns the certificate contained by this instance as a PEM encoded string of characters.

Returns:
The certificate as a PEM encoded string.


Copyright (c) 2010 Novell, Inc. All rights reserved.