org.xwiki.crypto.x509
Interface XWikiX509KeyPair

All Superinterfaces:
Serializable
All Known Implementing Classes:
DefaultXWikiX509KeyPair

public interface XWikiX509KeyPair
extends Serializable

Wrapper which contains a PrivateKey and the corresponding XWikiX509Certificate. This class is capable of holding a chain of certificates from the user's certificate back to the root certificate.

Since:
2.5M1

Field Summary
static String BASE64_FOOTER
          This will be at the end of the output from serializeAsBase64().
static String BASE64_HEADER
          This will be at the beginning of the output from serializeAsBase64().
 
Method Summary
 XWikiX509Certificate getCertificate()
          Get the user's certificate.
 String getFingerprint()
           
 PrivateKey getPrivateKey(String password)
          Get the private key from the key pair.
 PublicKey getPublicKey()
           
 byte[] serialize()
           
 String serializeAsBase64()
           
 

Field Detail

BASE64_HEADER

static final String BASE64_HEADER
This will be at the beginning of the output from serializeAsBase64().

See Also:
Constant Field Values

BASE64_FOOTER

static final String BASE64_FOOTER
This will be at the end of the output from serializeAsBase64().

See Also:
Constant Field Values
Method Detail

getCertificate

XWikiX509Certificate getCertificate()
Get the user's certificate. May throw a RuntimeException if the key pair was deserialized directly using Java deserialization methods without checking that the certificate can be deserialized.

Returns:
the user's certificate

getPublicKey

PublicKey getPublicKey()
Returns:
the public key

getPrivateKey

PrivateKey getPrivateKey(String password)
                         throws GeneralSecurityException
Get the private key from the key pair.

Parameters:
password - the password needed to decrypt the private key.
Returns:
the private key or null if the password is incorrect.
Throws:
GeneralSecurityException - if the private key cannot be decrypted.

getFingerprint

String getFingerprint()
Returns:
certificate fingerprint

serialize

byte[] serialize()
                 throws IOException
Returns:
this key pair as a byte array, the private key will remain password encrypted as it is in memory.
Throws:
IOException - if something goes wrong within the serialization framework.

serializeAsBase64

String serializeAsBase64()
                         throws IOException
Returns:
this key pair serialize()d and converted to a base-64 encoded String.
Throws:
IOException - if something goes wrong within the serialization framework.