1. /*
  2. * @(#)KeyPair.java 1.11 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.security;
  11. import java.util.*;
  12. /**
  13. * This class is a simple holder for a key pair (a public key and a
  14. * private key). It does not enforce any security, and, when initialized,
  15. * should be treated like a PrivateKey.
  16. *
  17. * @see PublicKey
  18. * @see PrivateKey
  19. *
  20. * @version 1.11 00/02/02
  21. * @author Benjamin Renaud
  22. */
  23. public final class KeyPair implements java.io.Serializable {
  24. private PrivateKey privateKey;
  25. private PublicKey publicKey;
  26. /**
  27. * Constructs a key pair from the given public key and private key.
  28. *
  29. * <p>Note that this constructor only stores references to the public
  30. * and private key components in the generated key pair. This is safe,
  31. * because <code>Key</code> objects are immutable.
  32. *
  33. * @param publicKey the public key.
  34. *
  35. * @param privateKey the private key.
  36. */
  37. public KeyPair(PublicKey publicKey, PrivateKey privateKey) {
  38. this.publicKey = publicKey;
  39. this.privateKey = privateKey;
  40. }
  41. /**
  42. * Returns a reference to the public key component of this key pair.
  43. *
  44. * @return a reference to the public key.
  45. */
  46. public PublicKey getPublic() {
  47. return publicKey;
  48. }
  49. /**
  50. * Returns a reference to the private key component of this key pair.
  51. *
  52. * @return a reference to the private key.
  53. */
  54. public PrivateKey getPrivate() {
  55. return privateKey;
  56. }
  57. }