home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / security / Key.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.7 KB  |  109 lines

  1. /*
  2.  * @(#)Key.java    1.38 98/03/18
  3.  *
  4.  * Copyright 1996, 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.security;
  16.  
  17. /**
  18.  * The Key interface is the top-level interface for all keys. It
  19.  * defines the functionality shared by all key objects. All keys
  20.  * have three characteristics:
  21.  * 
  22.  * <UL>
  23.  * 
  24.  * <LI>An Algorithm
  25.  * 
  26.  * <P>This is the key algorithm for that key. The key algorithm is usually
  27.  * an encryption or asymmetric operation algorithm (such as DSA or
  28.  * RSA), which will work with those algorithms and with related
  29.  * algorithms (such as MD5 with RSA, SHA-1 with RSA, Raw DSA, etc.)
  30.  * The name of the algorithm of a key is obtained using the 
  31.  * <a href = "#getAlgorithm">getAlgorithm</a> method.<P>
  32.  * 
  33.  * <LI>An Encoded Form
  34.  * 
  35.  * <P>This is an external encoded form for the key used when a standard
  36.  * representation of the key is needed outside the Java Virtual Machine,
  37.  * as when transmitting the key to some other party. The key
  38.  * is encoded according to a standard format (such as X.509 or PKCS#8), and
  39.  * is returned using the <a href = "#getEncoded">getEncoded</a> method.<P>
  40.  * 
  41.  * <LI>A Format
  42.  * 
  43.  * <P>This is the name of the format of the encoded key. It is returned 
  44.  * by the <a href = "#getFormat">getFormat</a> method.<P>
  45.  * 
  46.  * </UL>
  47.  * 
  48.  * Keys are generally obtained through key generators, certificates,
  49.  * or various Identity classes used to manage keys.
  50.  * Keys may also be obtained from key specifications (transparent
  51.  * representations of the underlying key material) through the use of a key
  52.  * factory (see <a href = "java.security.KeyFactory.html">KeyFactory</a>).  
  53.  *
  54.  * @see PublicKey
  55.  * @see PrivateKey
  56.  * @see KeyPair
  57.  * @see KeyPairGenerator
  58.  * @see KeyFactory
  59.  * @see java.security.spec.KeySpec
  60.  * @see Identity
  61.  * @see Signer
  62.  *
  63.  * @version 1.38 98/03/18
  64.  * @author Benjamin Renaud 
  65.  */
  66.  
  67. public interface Key extends java.io.Serializable {
  68.  
  69.     /**
  70.      * Returns the standard algorithm name for this key. For
  71.      * example, "DSA" would indicate that this key is a DSA key.
  72.      * See Appendix A in the <a href=
  73.      * "../guide/security/CryptoSpec.html#AppA">
  74.      * Java Cryptography Architecture API Specification & Reference </a> 
  75.      * for information about standard algorithm names.
  76.      * 
  77.      * @return the name of the algorithm associated with this key. 
  78.      */
  79.     public String getAlgorithm();
  80.  
  81.     /**
  82.      * Returns the name of the primary encoding format of this key, 
  83.      * or null if this key does not support encoding. 
  84.      * The primary encoding format is 
  85.      * named in terms of the appropriate ASN.1 data format, if an
  86.      * ASN.1 specification for this key exists.
  87.      * For example, the name of the ASN.1 data format for public 
  88.      * keys is <I>SubjectPublicKeyInfo</I>, as
  89.      * defined by the X.509 standard; in this case, the returned format is
  90.      * <code>"X.509"</code>. Similarly,
  91.      * the name of the ASN.1 data format for private keys is
  92.      * <I>PrivateKeyInfo</I>,
  93.      * as defined by the PKCS #8 standard; in this case, the returned format is
  94.      * <code>"PKCS#8"</code>.
  95.      * 
  96.      * @return the primary encoding format of the key.
  97.      */
  98.     public String getFormat();
  99.  
  100.     /**
  101.      * Returns the key in its primary encoding format, or null
  102.      * if this key does not support encoding.
  103.      * 
  104.      * @return the encoded key, or null if the key does not support
  105.      * encoding.
  106.      */
  107.     public byte[] getEncoded();
  108. }
  109.