public class KeyPair
extends java.lang.Object
implements java.io.Serializable
This class holds a PrivateKey and PublicKey pair. The PublicKey needs to be wrapped by an X509Certificate for verification.
Constructor and Description |
---|
KeyPair(java.security.cert.Certificate[] certChain,
java.security.Key privateKey)
This constructor accepts a certificate chain and a private key.
|
KeyPair(java.security.Key publicKey,
java.security.Key privateKey)
This constructor accepts a public and private key pair.
|
Modifier and Type | Method and Description |
---|---|
java.security.cert.Certificate |
getCertificate()
This method is used to retrieve the first certificate in the certChain.
|
java.security.cert.Certificate[] |
getCertificateChain()
This method is used to retrieve the certChain.
|
java.security.Key |
getPrivateKey()
This method is used to retrieve the PrivateKey.
|
java.security.Key |
getPublicKey()
This method is used to retrieve the publicKey.
|
public KeyPair(java.security.cert.Certificate[] certChain, java.security.Key privateKey)
This constructor accepts a certificate chain and a private key. The public key is contained within the certificate. When using this contructor to create a KeyPair, the certificate and private key can be stored in any KeyStore type as a single alias.
java.security.cert.Certificate[]
- certChainjava.security.Key
- privateKeypublic KeyPair(java.security.Key publicKey, java.security.Key privateKey)
This constructor accepts a public and private key pair. There are some situations where having a certificate associated with the public key is not possible. When creating a key pair this way, the public and private keys will be stored in a KeyStore as "secret" keys using alias + "_public" and alias + "_private" as the alias in the keystore. Because they are stored this way, the KeyStore type must allow the storage of SecretKeys such as JCEKS. Make sure the configuration of the KeySet is associated with a JCEKS (or keystore of similiar function) or an error will occur.
java.security.Key
- publicKeyjava.security.Key
- privateKeypublic java.security.cert.Certificate[] getCertificateChain()
This method is used to retrieve the certChain.
public java.security.cert.Certificate getCertificate()
This method is used to retrieve the first certificate in the certChain. This certicate contains the PublicKey that goes with the PrivateKey.
public java.security.Key getPrivateKey()
This method is used to retrieve the PrivateKey.
public java.security.Key getPublicKey()
This method is used to retrieve the publicKey. If this method is not null while the getCerticateChain method returns null, then this key pair was created without a certificate.