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

FileImageInputStream(RandomAccessFile) does not throw SecurityException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: mlR10151 Date: 04/12/2001



      The spec for the "public FileImageInputStream(RandomAccessFile raf)" reads:

      Throws:
       . . .
                  SecurityException - if a security manager exists and does not allow read access to the file.

      But it does not throw SecurityException:

      ========================== a.java =============================
      import java.io.*;
      import java.security.*;
      import javax.imageio.stream.*;

      public class a {
          public static void main (String argv[]) throws Exception {
              System.setSecurityManager(null);
              RandomAccessFile raf = new RandomAccessFile("a.java", "r");
              System.setSecurityManager(new mySecMgr());

              try {
                  new FileImageInputStream(raf);
                  System.out.println("Failed");
              } catch (SecurityException e) {
                  System.out.println("Passed");
              }
          }
      }

      class mySecMgr extends SecurityManager {
          public mySecMgr() {}
          public void checkRead(String file) { throw new SecurityException(); }
          public void checkRead(FileDescriptor fdObj) { throw new SecurityException(); }
          public void checkRead(String file, Object context) { throw new SecurityException(); }
          public void checkPermission(Permission perm) { throw new SecurityException(); }
          public void checkPermission(Permission perm, Object context) { throw new SecurityException(); }
      }
      ===========================log========================
      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b59)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b59, mixed mode)
      % java a
      Failed

      This bug causes failure of the new JCK test
      api/javax_imageio/stream/FileImageInputStream/index.html#Ctor


      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            dricesunw Daniel Rice (Inactive)
            Reporter:
            mlsunw Ml Ml (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: