1. /*
  2. * @(#)EncodedKeySpec.java 1.13 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.spec;
  8. /**
  9. * This class represents a public or private key in encoded format.
  10. *
  11. * @author Jan Luehe
  12. *
  13. * @version 1.13 01/11/29
  14. *
  15. * @see java.security.Key
  16. * @see java.security.KeyFactory
  17. * @see KeySpec
  18. * @see X509EncodedKeySpec
  19. * @see PKCS8EncodedKeySpec
  20. *
  21. * @since JDK1.2
  22. */
  23. public abstract class EncodedKeySpec implements KeySpec {
  24. private byte[] encodedKey;
  25. /**
  26. * Creates a new EncodedKeySpec with the given encoded key.
  27. *
  28. * @param encodedKey the encoded key.
  29. */
  30. public EncodedKeySpec(byte[] encodedKey) {
  31. this.encodedKey = (byte[])encodedKey.clone();
  32. }
  33. /**
  34. * Returns the encoded key.
  35. *
  36. * @return the encoded key.
  37. */
  38. public byte[] getEncoded() {
  39. return (byte[])this.encodedKey.clone();
  40. }
  41. /**
  42. * Returns the name of the encoding format associated with this
  43. * key specification.
  44. *
  45. * <p>If the opaque representation of a key
  46. * (see {@link java.security.Key Key}) can be transformed
  47. * (see {@link java.security.KeyFactory KeyFactory})
  48. * into this key specification (or a subclass of it),
  49. * <code>getFormat</code> called
  50. * on the opaque key returns the same value as the
  51. * <code>getFormat</code> method
  52. * of this key specification.
  53. *
  54. * @return a string representation of the encoding format.
  55. */
  56. public abstract String getFormat();
  57. }