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

java.security.auth.login.config path spaces with jaas.conf outside jar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 6u23
    • security-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_23"
      Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Independent of OS. Tested on Windows XP, Windows Vista, Suse 11.2

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Client machine connected to a windows active directory domain. Kerberos authentication to active directory within java code.

      A DESCRIPTION OF THE PROBLEM :
      The path to a jaas.conf file, located outside a jar, cannot contain spaces or it will fail.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a folder named "conf" and place jaas.conf within the "conf" folder.
      Create an executable jar with a java class containing the following code:
      System.setProperty( "java.security.auth.login.config", Class.forName("MyClass").getResource("conf/jaas.conf").toString( ) );
      Place the jar in a folder whose name contains spaces.
      Place "conf" folder in same folder as the jar.
      Execute the jar.

      --ISSUE--
      The jaas.conf cannot be found.
      --ISSUE--

      Workaround 1:
      Place "conf" folder within jar. No more issues.

      Workaround 2:
      Rename all folders in path to jar to eliminate spaces (all the way to root or drive letter). No more issues.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting the jaas.conf to be found.
      ACTUAL -
      The jaas.conf file cannot be found.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.SecurityException: /mnt/JavaDev/AccessManager/spaces%20test/conf/jaas.conf (No such file or directory)
      at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:93)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at javax.security.auth.login.Configuration$3.run(Configuration.java:247)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:242)
      at javax.security.auth.login.LoginContext$1.run(LoginContext.java:237)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.init(LoginContext.java:234)
      at javax.security.auth.login.LoginContext.<init>(LoginContext.java:403)
      at MriConnection.getConnection(MriConnection.java:157)
      at AccessDatabase.establishConnection(AccessDatabase.java:55)
      at AccessSplash.loadAction(AccessSplash.java:119)
      at MriSplash$1.run(MriSplash.java:150)
      Caused by: java.io.FileNotFoundException: /mnt/JavaDev/AccessManager/spaces%20test/conf/jaas.conf (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(FileInputStream.java:106)
      at java.io.FileInputStream.<init>(FileInputStream.java:66)
      at com.sun.security.auth.login.ConfigFile.getInputStream(ConfigFile.java:591)
      at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:260)
      at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:202)
      at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:91)
      ... 17 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Include this anywhere in your class. Replace "MyClass", "MyRealm", and "MyKDC" with appropriate values:

      System.setProperty( "java.security.auth.login.config", Class.forName("MyClass").getResource("conf/jaas.conf").toString( ) );
      System.setProperty( "java.security.krb5.realm", "MyRealm" );
      System.setProperty( "java.security.krb5.kdc", "MyKDC" );

      LoginContext context = new LoginContext( "Kerberos", new DialogCallbackHandler( ) );
      context.login( );
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Workaround 1:
      Place "conf" folder within jar. No more issues.

      Workaround 2:
      Rename all folders in path to jar to eliminate spaces (all the way to root or drive letter). No more issues.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: