Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5002202

engineGenerateCertPath: missed default behavior

XMLWordPrintable

    • b48
    • generic
    • generic
    • Verified

      To keep integrity of the class CertificateFactorySpi the description of the
      method engineGenerateCertPath(InputStream inStream) should be supplemented
      with default behavior. It should say that by default the method throws an
      UnsupportedOperationException.

      Here are the reasons:
      All methods of CertificateFactorySpi class are abstract or by default throw
      an UnsupportedOperationException. Only description of one method doesn't
      specify default behavior.

      The spec. says:

      "public CertPath engineGenerateCertPath(InputStream inStream)
           throws CertificateException

        Generates a CertPath object and initializes it with the data read from the
        InputStream inStream. The data is assumed to be in the default encoding.

        Parameters: inStream - an InputStream containing the data
           Returns: a CertPath initialized with the data from the InputStream
            Throws: CertificateException - if an exception occurs while decoding"

      So, only CertificateException can be thrown by engineGenerateCertPath method.
      But the java throws UnsupportedOperationException.
      See example below,
      --------------------------test.java--------------------------
      import java.security.cert.*;
      import java.io.InputStream;
      import java.util.Collection;
      public class test extends CertificateFactorySpi {

          public Certificate engineGenerateCertificate(InputStream inStream)
              throws CertificateException { return null; };
          public Collection engineGenerateCertificates(InputStream inStream)
              throws CertificateException { return null; };
          public CRL engineGenerateCRL(InputStream inStream)
              throws CRLException { return null; };
          public Collection engineGenerateCRLs(InputStream inStream)
              throws CRLException { return null; };

          public static void main(String[] av)
          {
              test t = new test();
              try {
                  t.engineGenerateCertPath((InputStream)null);
              } catch (CertificateException ce) {
              } catch (Exception e) {
                  System.out.println("Unexpected exception: " + e);
              }
          }
      }
      --------------------------output--------------------------
      Unexpected exception: java.lang.UnsupportedOperationException
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
      ===================
      Unexpected exception: java.lang.UnsupportedOperationException
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b39)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b39, mixed mode)

            vinnie Vincent Ryan
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: