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

  1. /*
  2.  * @(#)AlgorithmParametersSpi.java    1.3 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 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. import java.io.*;
  18. import java.security.spec.AlgorithmParameterSpec;
  19. import java.security.spec.InvalidParameterSpecException;
  20.  
  21. /**
  22.  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
  23.  * for the <code>AlgorithmParameters</code> class, which is used to manage
  24.  * algorithm parameters.
  25.  *
  26.  * <p> All the abstract methods in this class must be implemented by each 
  27.  * cryptographic service provider who wishes to supply parameter management
  28.  * for a particular algorithm.
  29.  *
  30.  * @author Jan Luehe
  31.  *
  32.  * @version 1.3, 98/03/18
  33.  *
  34.  * @see AlgorithmParameters
  35.  * @see java.security.spec.AlgorithmParameterSpec
  36.  * @see java.security.spec.DSAParameterSpec
  37.  *
  38.  * @since JDK1.2
  39.  */
  40.  
  41. public abstract class AlgorithmParametersSpi {
  42.  
  43.     /**
  44.      * Initializes this parameters object using the parameters 
  45.      * specified in <code>paramSpec</code>.
  46.      *
  47.      * @param paramSpec the parameter specification.
  48.      *
  49.      * @exception InvalidParameterSpecException if the given parameter
  50.      * specification is inappropriate for the initialization of this parameter
  51.      * object.
  52.      */
  53.     protected abstract void engineInit(AlgorithmParameterSpec paramSpec) 
  54.     throws InvalidParameterSpecException;
  55.  
  56.     /**
  57.      * Imports the specified parameters and decodes them
  58.      * according to the primary decoding format for parameters.
  59.      * The primary decoding format for parameters is ASN.1, if an ASN.1
  60.      * specification for this type of parameters exists.
  61.      *
  62.      * @param params the encoded parameters.
  63.      *
  64.      * @exception IOException on decoding errors
  65.      */
  66.     protected abstract void engineInit(byte[] params)
  67.     throws IOException;
  68.  
  69.     /**
  70.      * Imports the parameters from <code>params</code> and
  71.      * decodes them according to the specified decoding format.
  72.      * If <code>format</code> is null, the
  73.      * primary decoding format for parameters is used. The primary decoding
  74.      * format is ASN.1, if an ASN.1 specification for these parameters
  75.      * exists.
  76.      *
  77.      * @param params the encoded parameters.
  78.      *
  79.      * @param format the name of the decoding format.
  80.      *
  81.      * @exception IOException on decoding errors
  82.      */
  83.     protected abstract void engineInit(byte[] params, String format)
  84.     throws IOException;
  85.  
  86.     /**
  87.      * Returns a (transparent) specification of this parameters
  88.      * object.
  89.      * <code>paramSpec</code> identifies the specification class in which 
  90.      * the parameters should be returned. It could, for example, be
  91.      * <code>DSAParameterSpec.class</code>, to indicate that the
  92.      * parameters should be returned in an instance of the 
  93.      * <code>DSAParameterSpec</code> class.
  94.      *
  95.      * @param paramSpec the the specification class in which 
  96.      * the parameters should be returned.
  97.      *
  98.      * @return the parameter specification.
  99.      *
  100.      * @exception InvalidParameterSpecException if the requested parameter
  101.      * specification is inappropriate for this parameter object.
  102.      */
  103.     protected abstract
  104.     AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
  105.     throws InvalidParameterSpecException;
  106.  
  107.     /**
  108.      * Returns the parameters in their primary encoding format.
  109.      * The primary encoding format for parameters is ASN.1, if an ASN.1
  110.      * specification for this type of parameters exists.
  111.      *
  112.      * @return the parameters encoded using the specified encoding scheme.
  113.      *
  114.      * @exception IOException on encoding errors.
  115.      */
  116.     protected abstract byte[] engineGetEncoded() throws IOException;
  117.  
  118.     /**
  119.      * Returns the parameters encoded in the specified format.
  120.      * If <code>format</code> is null, the
  121.      * primary encoding format for parameters is used. The primary encoding
  122.      * format is ASN.1, if an ASN.1 specification for these parameters
  123.      * exists.
  124.      *
  125.      * @param format the name of the encoding format.
  126.      *
  127.      * @return the parameters encoded using the specified encoding scheme.
  128.      *
  129.      * @exception IOException on encoding errors.
  130.      */
  131.     protected abstract byte[] engineGetEncoded(String format)
  132.     throws IOException;
  133.  
  134.     /**
  135.      * Returns a formatted string describing the parameters.
  136.      *
  137.      * @return a formatted string describing the parameters.
  138.      */
  139.     protected abstract String engineToString();
  140. }
  141.