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

wrong exception in javax.crypto.SealedObject.getObject(Key k, String provider)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • security-libs
    • b28
    • sparc
    • solaris_2.6
    • Verified



      Name: ktR10099 Date: 10/17/2003



      While calling getObject(Key k, String provider) with valid key and null
      string method throws IllegalArgumentException. This behavior contadicts to
      the spec, besides, in such situation NullPointerException seems to be more
      appropriate. Please find below test example, demonstrating the bug.
      ----------------------------test127.java--------------------------
      import javax.security.auth.kerberos.*;
      import javax.crypto.*;
      import java.security.*;

      public class test127 {
          public static void main(String[] args) {
              Cipher c = null;
              SealedObject so = null;
              String provider = null;
              char[] passwd = new String("password").toCharArray();
              KerberosPrincipal kp = new KerberosPrincipal("###@###.###");
              Key k = new KerberosKey(kp, passwd, "DES");

              try {
                  c = Cipher.getInstance("DES");
                  c.init(Cipher.ENCRYPT_MODE, k);
                  so = new SealedObject("Test string", c);
              } catch (Exception e) {
                  System.out.println("1. Unexpected exception : " + e);
              }
              try {
                  Object o = so.getObject(k, null);
                  System.out.println("Unsealed object : " + o);
              } catch (Exception e) {
                  System.out.println("2. Unexpected exception : " + e);
              }
              System.out.println("Finished");
          }
      }
      ------------------------------output of test127----------------------
      java full version "1.5.0-beta-b23"
      2. Unexpected exception : java.lang.IllegalArgumentException: missing provider
      Finished
      ---------------------------------------------------------------------
      ======================================================================

            valeriep Valerie Peng
            kvtsunw Kvt Kvt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: