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

getCanonicalPath() and getCanonicalFile() methods of java.io.File require "read"

    Details

    • Subcomponent:
    • Resolved In Build:
      b40
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      Description



      Name: szR10253 Date: 11/13/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b28"
      JCK : 1.5
      Platform[s] : Win2000
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] :
          api/java_io/File/descriptions.html#getCPath[File0102]


      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      public String getCanonicalPath() throws IOException
          Throws:
              SecurityException - If a required system property value cannot be accessed.


      public File getCanonicalFile() throws IOException

          Returns the canonical form of this abstract pathname. Equivalent to new File(this.getCanonicalPath()()).

          Throws:
              SecurityException - If a required system property value cannot be accessed.


      ...
      ---------- end-of-excerpt ---------------

      Problem description
      ===================
      On Windows 2000 these methods require "read" permission to a file though this is not specified.

          
      Minimized test:
      ===============
      ------- Test.java -------

      import java.io.File;
      import java.io.IOException;

      public class Test {

          public static void main(String[] args) {
              System.setSecurityManager(new SM());
              try {
                  new File("", "file").getCanonicalPath();
                  new File("", "file").getCanonicalFile();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }

          static class SM extends SecurityManager {
              public void checkPropertyAccess(String key) {
              }
              public void checkRead(String file) {
                  super.checkRead(file);
              }
          }
      }

      ------- end-of-Test.java -------

      Minimized test output:
      ======================
      Exception in thread "main" java.security.AccessControlException: access denied (
      java.io.FilePermission F:\file read)
              at java.security.AccessControlContext.checkPermission(AccessControlConte
      xt.java:264)
              at java.security.AccessController.checkPermission(AccessController.java:
      401)
              at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
              at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
              at Test$SM.checkRead(Test.java:21)
              at java.io.File.exists(File.java:692)
              at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:401)
              at java.io.File.getCanonicalPath(File.java:526)
              at Test.main(Test.java:10)

      JCK test source location:
      ==========================
      /java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

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

        Attachments

          Activity

            People

            • Assignee:
              mmcclosksunw Michael Mccloskey (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: