41 import java.io.File; |
41 import java.io.File; |
42 import java.io.FileInputStream; |
42 import java.io.FileInputStream; |
43 import java.io.FileOutputStream; |
43 import java.io.FileOutputStream; |
44 import java.io.BufferedReader; |
44 import java.io.BufferedReader; |
45 import java.io.InputStreamReader; |
45 import java.io.InputStreamReader; |
46 import java.lang.reflect.*; |
|
47 |
46 |
48 /** |
47 /** |
49 * CredentialsCache stores credentials(tickets, session keys, etc) in a |
48 * CredentialsCache stores credentials(tickets, session keys, etc) in a |
50 * semi-permanent store |
49 * semi-permanent store |
51 * for later use by different program. |
50 * for later use by different program. |
386 java.security.AccessController.doPrivileged( |
385 java.security.AccessController.doPrivileged( |
387 new sun.security.action.GetPropertyAction("os.name")); |
386 new sun.security.action.GetPropertyAction("os.name")); |
388 |
387 |
389 /* |
388 /* |
390 * For Unix platforms we use the default cache name to be |
389 * For Unix platforms we use the default cache name to be |
391 * /tmp/krbcc_uid ; for all other platforms we use |
390 * /tmp/krb5cc_uid ; for all other platforms we use |
392 * {user_home}/krb5_cc{user_name} |
391 * {user_home}/krb5cc_{user_name} |
393 * Please note that for Windows 2K we will use LSA to get |
392 * Please note that for Windows we will use LSA to get |
394 * the TGT from the the default cache even before we come here; |
393 * the TGT from the the default cache even before we come here; |
395 * however when we create cache we will create a cache under |
394 * however when we create cache we will create a cache under |
396 * {user_home}/krb5_cc{user_name} for non-Unix platforms including |
395 * {user_home}/krb5cc_{user_name} for non-Unix platforms including |
397 * Windows 2K. |
396 * Windows. |
398 */ |
397 */ |
399 |
398 |
400 if (osname != null) { |
399 if (osname != null && !osname.startsWith("Windows")) { |
401 String cmd = null; |
400 long uid = sun.misc.VM.getuid(); |
402 String uidStr = null; |
401 if (uid != -1) { |
403 long uid = 0; |
402 name = File.separator + "tmp" + |
404 |
|
405 if (osname.startsWith("SunOS") || |
|
406 (osname.startsWith("Linux"))) { |
|
407 try { |
|
408 Class<?> c = Class.forName |
|
409 ("com.sun.security.auth.module.UnixSystem"); |
|
410 Constructor<?> constructor = c.getConstructor(); |
|
411 Object obj = constructor.newInstance(); |
|
412 Method method = c.getMethod("getUid"); |
|
413 uid = ((Long)method.invoke(obj)).longValue(); |
|
414 name = File.separator + "tmp" + |
|
415 File.separator + stdCacheNameComponent + "_" + uid; |
403 File.separator + stdCacheNameComponent + "_" + uid; |
416 if (DEBUG) { |
404 if (DEBUG) { |
417 System.out.println(">>>KinitOptions cache name is " + |
405 System.out.println(">>>KinitOptions cache name is " + |
418 name); |
406 name); |
419 } |
407 } |
420 return name; |
408 return name; |
421 } catch (Exception e) { |
409 } else { |
422 if (DEBUG) { |
410 if (DEBUG) { |
423 System.out.println("Exception in obtaining uid " + |
411 System.out.println("Error in obtaining uid " + |
424 "for Unix platforms " + |
412 "for Unix platforms " + |
425 "Using user's home directory"); |
413 "Using user's home directory"); |
426 |
|
427 |
|
428 e.printStackTrace(); |
|
429 } |
|
430 } |
414 } |
431 } |
415 } |
432 } |
416 } |
433 |
417 |
434 // we did not get the uid; |
418 // we did not get the uid; |
435 |
|
436 |
419 |
437 String user_name = |
420 String user_name = |
438 java.security.AccessController.doPrivileged( |
421 java.security.AccessController.doPrivileged( |
439 new sun.security.action.GetPropertyAction("user.name")); |
422 new sun.security.action.GetPropertyAction("user.name")); |
440 |
423 |