equal
deleted
inserted
replaced
43 import java.security.PrivilegedExceptionAction; |
43 import java.security.PrivilegedExceptionAction; |
44 import java.util.regex.Matcher; |
44 import java.util.regex.Matcher; |
45 import java.util.regex.Pattern; |
45 import java.util.regex.Pattern; |
46 |
46 |
47 import sun.net.dns.ResolverConfiguration; |
47 import sun.net.dns.ResolverConfiguration; |
|
48 import sun.security.action.GetPropertyAction; |
48 import sun.security.krb5.internal.crypto.EType; |
49 import sun.security.krb5.internal.crypto.EType; |
49 import sun.security.krb5.internal.Krb5; |
50 import sun.security.krb5.internal.Krb5; |
50 |
51 |
51 /** |
52 /** |
52 * This class maintains key-value pairs of Kerberos configurable constants |
53 * This class maintains key-value pairs of Kerberos configurable constants |
120 } |
121 } |
121 |
122 |
122 |
123 |
123 private static boolean isMacosLionOrBetter() { |
124 private static boolean isMacosLionOrBetter() { |
124 // split the "10.x.y" version number |
125 // split the "10.x.y" version number |
125 String osname = getProperty("os.name"); |
126 String osname = GetPropertyAction.privilegedGetProperty("os.name"); |
126 if (!osname.contains("OS X")) { |
127 if (!osname.contains("OS X")) { |
127 return false; |
128 return false; |
128 } |
129 } |
129 |
130 |
130 String osVersion = getProperty("os.version"); |
131 String osVersion = GetPropertyAction.privilegedGetProperty("os.version"); |
131 String[] fragments = osVersion.split("\\."); |
132 String[] fragments = osVersion.split("\\."); |
132 |
133 |
133 // sanity check the "10." part of the version |
134 // sanity check the "10." part of the version |
134 if (!fragments[0].equals("10")) return false; |
135 if (!fragments[0].equals("10")) return false; |
135 if (fragments.length < 2) return false; |
136 if (fragments.length < 2) return false; |
150 */ |
151 */ |
151 private Config() throws KrbException { |
152 private Config() throws KrbException { |
152 /* |
153 /* |
153 * If either one system property is specified, we throw exception. |
154 * If either one system property is specified, we throw exception. |
154 */ |
155 */ |
155 String tmp = getProperty("java.security.krb5.kdc"); |
156 String tmp = GetPropertyAction |
|
157 .privilegedGetProperty("java.security.krb5.kdc"); |
156 if (tmp != null) { |
158 if (tmp != null) { |
157 // The user can specify a list of kdc hosts separated by ":" |
159 // The user can specify a list of kdc hosts separated by ":" |
158 defaultKDC = tmp.replace(':', ' '); |
160 defaultKDC = tmp.replace(':', ' '); |
159 } else { |
161 } else { |
160 defaultKDC = null; |
162 defaultKDC = null; |
161 } |
163 } |
162 defaultRealm = getProperty("java.security.krb5.realm"); |
164 defaultRealm = GetPropertyAction |
|
165 .privilegedGetProperty("java.security.krb5.realm"); |
163 if ((defaultKDC == null && defaultRealm != null) || |
166 if ((defaultKDC == null && defaultRealm != null) || |
164 (defaultRealm == null && defaultKDC != null)) { |
167 (defaultRealm == null && defaultKDC != null)) { |
165 throw new KrbException |
168 throw new KrbException |
166 ("System property java.security.krb5.kdc and " + |
169 ("System property java.security.krb5.kdc and " + |
167 "java.security.krb5.realm both must be set or " + |
170 "java.security.krb5.realm both must be set or " + |
816 * and return it if the file exists. |
819 * and return it if the file exists. |
817 * |
820 * |
818 * The method returns null if it cannot find a Java config file. |
821 * The method returns null if it cannot find a Java config file. |
819 */ |
822 */ |
820 private String getJavaFileName() { |
823 private String getJavaFileName() { |
821 String name = getProperty("java.security.krb5.conf"); |
824 String name = GetPropertyAction |
|
825 .privilegedGetProperty("java.security.krb5.conf"); |
822 if (name == null) { |
826 if (name == null) { |
823 name = getProperty("java.home") + File.separator + |
827 name = GetPropertyAction.privilegedGetProperty("java.home") |
824 "conf" + File.separator + "security" + |
828 + File.separator + "conf" + File.separator + "security" |
825 File.separator + "krb5.conf"; |
829 + File.separator + "krb5.conf"; |
826 if (!fileExists(name)) { |
830 if (!fileExists(name)) { |
827 name = null; |
831 name = null; |
828 } |
832 } |
829 } |
833 } |
830 if (DEBUG) { |
834 if (DEBUG) { |
850 * This method will always return a non-null non-empty file name, |
854 * This method will always return a non-null non-empty file name, |
851 * even if that file does not exist. |
855 * even if that file does not exist. |
852 */ |
856 */ |
853 private String getNativeFileName() { |
857 private String getNativeFileName() { |
854 String name = null; |
858 String name = null; |
855 String osname = getProperty("os.name"); |
859 String osname = GetPropertyAction.privilegedGetProperty("os.name"); |
856 if (osname.startsWith("Windows")) { |
860 if (osname.startsWith("Windows")) { |
857 try { |
861 try { |
858 Credentials.ensureLoaded(); |
862 Credentials.ensureLoaded(); |
859 } catch (Exception e) { |
863 } catch (Exception e) { |
860 // ignore exceptions |
864 // ignore exceptions |
897 System.out.println("Native config name: " + name); |
901 System.out.println("Native config name: " + name); |
898 } |
902 } |
899 return name; |
903 return name; |
900 } |
904 } |
901 |
905 |
902 private static String getProperty(String property) { |
|
903 return java.security.AccessController.doPrivileged( |
|
904 new sun.security.action.GetPropertyAction(property)); |
|
905 } |
|
906 |
|
907 private String findMacosConfigFile() { |
906 private String findMacosConfigFile() { |
908 String userHome = getProperty("user.home"); |
907 String userHome = GetPropertyAction.privilegedGetProperty("user.home"); |
909 final String PREF_FILE = "/Library/Preferences/edu.mit.Kerberos"; |
908 final String PREF_FILE = "/Library/Preferences/edu.mit.Kerberos"; |
910 String userPrefs = userHome + PREF_FILE; |
909 String userPrefs = userHome + PREF_FILE; |
911 |
910 |
912 if (fileExists(userPrefs)) { |
911 if (fileExists(userPrefs)) { |
913 return userPrefs; |
912 return userPrefs; |