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

(spec) javax.crypto.SealedObject.getObject(Key, String): NPE is not specified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0
    • security-libs
    • beta
    • generic
    • generic

      Method javax.crypto.SealedObject.getObject(Key key, String provider) throws NullPointerException if key paramter is null. Such behavior is not specified and should be documented. Here is an example:
      -----------------------------------------------------
      import javax.crypto.SealedObject;
      import javax.crypto.IllegalBlockSizeException;
      import javax.crypto.Cipher;
      import javax.crypto.NoSuchPaddingException;
      import javax.crypto.spec.SecretKeySpec;
      import java.io.IOException;
      import java.io.Serializable;
      import java.security.*;

      public class C implements Serializable {
          public static void main(String argv[]) throws NoSuchAlgorithmException, NoSuchPaddingException, IOException, IllegalBlockSizeException, InvalidKeyException {
              Cipher c = Cipher.getInstance("DES");
              Key k = new SecretKeySpec(new byte[8], "DES");
              c.init(Cipher.ENCRYPT_MODE, k);
              String providerName = c.getProvider().getName();
              SealedObject so = new SealedObject(new C(), c);
              try {
                  so.getObject((Key)null, providerName);
              } catch (ClassNotFoundException e) {
                  System.out.println("ClassNotFoundException was thrown");
              } catch (NoSuchProviderException e) {
                  System.out.println("NoSuchProviderException was thrown");
              } catch (NullPointerException e) {
                  System.out.println("NPE was thrown");
              }


          }
      }
      ------------------------------------
      aag@gaff:~/work/bugs/doc> javac C.java;java C
      NPE was thrown
      ###@###.### 2004-12-08 13:36:51 GMT

            wetmore Bradford Wetmore
            agavrilosunw Alexey Gavrilov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: