Package java.security

Class KeyPair

java.lang.Object
java.security.KeyPair
All Implemented Interfaces:
Serializable

public final class KeyPair
extends Object
implements Serializable
KeyPair is a container for a public key and a private key. Since the private key can be accessed, instances must be treated like a private key.
See Also:
PrivateKey, PublicKey, Serialized Form
  • Constructor Details

    • KeyPair

      public KeyPair​(PublicKey publicKey, PrivateKey privateKey)
      Constructs a new instance of KeyPair with a public key and the corresponding private key.
      Parameters:
      publicKey - the public key.
      privateKey - the private key.
  • Method Details

    • getPrivate

      public PrivateKey getPrivate()
      Returns the private key.
      Returns:
      the private key.
    • getPublic

      public PublicKey getPublic()
      Returns the public key.
      Returns:
      the public key.