Top Description Fields Constructors Methods
java.security

public final Class KeyPair

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

This class is a simple holder for a key pair (a public key and a private key). It does not enforce any security, and, when initialized, should be treated like a PrivateKey.
Author
Benjamin Renaud
Since
1.1
See Also
PublicKey, PrivateKey

Field Summary

Modifier and TypeField and Description
private final PrivateKey
privateKey

The private key.

private final PublicKey
publicKey

The public key.

private static final long

Constructor Summary

AccessConstructor and Description
public
KeyPair(PublicKey
the public key.
publicKey
,
PrivateKey
the private key.
privateKey
)

Constructs a key pair from the given public key and private key.

Method Summary

Modifier and TypeMethod and Description
public PrivateKey

Returns:

a reference to the private key.
getPrivate
()

Returns a reference to the private key component of this key pair.

public PublicKey

Returns:

a reference to the public key.
getPublic
()

Returns a reference to the public key component of this key pair.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

privateKeyback to summary
private final PrivateKey privateKey

The private key.

publicKeyback to summary
private final PublicKey publicKey

The public key.

serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

KeyPairback to summary
public KeyPair(PublicKey publicKey, PrivateKey privateKey)

Constructs a key pair from the given public key and private key.

Note that this constructor only stores references to the public and private key components in the generated key pair. This is safe, because Key objects are immutable.

Parameters
publicKey:PublicKey

the public key.

privateKey:PrivateKey

the private key.

Method Detail

getPrivateback to summary
public PrivateKey getPrivate()

Returns a reference to the private key component of this key pair.

Returns:PrivateKey

a reference to the private key.

getPublicback to summary
public PublicKey getPublic()

Returns a reference to the public key component of this key pair.

Returns:PublicKey

a reference to the public key.