1. /*
  2. * @(#)EncodedKeySpec.java 1.16 00/02/02
  3. *
  4. * Copyright 1997-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.spec;
  11. /**
  12. * This class represents a public or private key in encoded format.
  13. *
  14. * @author Jan Luehe
  15. *
  16. * @version 1.16, 02/02/00
  17. *
  18. * @see java.security.Key
  19. * @see java.security.KeyFactory
  20. * @see KeySpec
  21. * @see X509EncodedKeySpec
  22. * @see PKCS8EncodedKeySpec
  23. *
  24. * @since 1.2
  25. */
  26. public abstract class EncodedKeySpec implements KeySpec {
  27. private byte[] encodedKey;
  28. /**
  29. * Creates a new EncodedKeySpec with the given encoded key.
  30. *
  31. * @param encodedKey the encoded key.
  32. */
  33. public EncodedKeySpec(byte[] encodedKey) {
  34. this.encodedKey = (byte[])encodedKey.clone();
  35. }
  36. /**
  37. * Returns the encoded key.
  38. *
  39. * @return the encoded key.
  40. */
  41. public byte[] getEncoded() {
  42. return (byte[])this.encodedKey.clone();
  43. }
  44. /**
  45. * Returns the name of the encoding format associated with this
  46. * key specification.
  47. *
  48. * <p>If the opaque representation of a key
  49. * (see {@link java.security.Key Key}) can be transformed
  50. * (see {@link java.security.KeyFactory KeyFactory})
  51. * into this key specification (or a subclass of it),
  52. * <code>getFormat</code> called
  53. * on the opaque key returns the same value as the
  54. * <code>getFormat</code> method
  55. * of this key specification.
  56. *
  57. * @return a string representation of the encoding format.
  58. */
  59. public abstract String getFormat();
  60. }