java.security
Class KeyPair

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.KeyPair
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public final class KeyPair
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for 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.

See Also:
PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey , PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey , Serialized Form

Constructor Summary
KeyPair sample code for java.security.KeyPair.KeyPair(java.security.PublicKey, java.security.PrivateKey) definition code for java.security.KeyPair.KeyPair(java.security.PublicKey, java.security.PrivateKey) (PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  publicKey, PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  privateKey)
          Constructs a key pair from the given public key and private key.
 
Method Summary
 PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey getPrivate sample code for java.security.KeyPair.getPrivate() definition code for java.security.KeyPair.getPrivate() ()
          Returns a reference to the private key component of this key pair.
 PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey getPublic sample code for java.security.KeyPair.getPublic() definition code for java.security.KeyPair.getPublic() ()
          Returns a reference to the public key component of this key pair.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

KeyPair sample code for java.security.KeyPair(java.security.PublicKey, java.security.PrivateKey) definition code for java.security.KeyPair(java.security.PublicKey, java.security.PrivateKey)

public KeyPair(PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  publicKey,
               PrivateKey sample code for java.security.PrivateKey definition code for java.security.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 - the public key.
privateKey - the private key.
Method Detail

getPublic sample code for java.security.KeyPair.getPublic() definition code for java.security.KeyPair.getPublic()

public PublicKey sample code for java.security.PublicKey definition code for java.security.PublicKey  getPublic()
Returns a reference to the public key component of this key pair.

Returns:
a reference to the public key.

getPrivate sample code for java.security.KeyPair.getPrivate() definition code for java.security.KeyPair.getPrivate()

public PrivateKey sample code for java.security.PrivateKey definition code for java.security.PrivateKey  getPrivate()
Returns a reference to the private key component of this key pair.

Returns:
a reference to the private key.