changeset 6834:d6d233ee9422

8022931: Enhance Kerberos exceptions Reviewed-by: xuelei, ahgross
author weijun
date Sat, 17 Aug 2013 06:51:46 +0800
parents 050746671449
children c0ff56eaaa96
files src/share/classes/javax/security/auth/kerberos/KeyTab.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/security/auth/kerberos/KeyTab.java	Thu Aug 15 11:46:56 2013 -0400
+++ b/src/share/classes/javax/security/auth/kerberos/KeyTab.java	Sat Aug 17 06:51:46 2013 +0800
@@ -26,6 +26,7 @@
 package javax.security.auth.kerberos;
 
 import java.io.File;
+import java.security.AccessControlException;
 import java.util.Objects;
 import sun.misc.SharedSecrets;
 import sun.security.krb5.EncryptionKey;
@@ -114,7 +115,19 @@
 
     //Takes a snapshot of the keytab content
     private sun.security.krb5.internal.ktab.KeyTab takeSnapshot() {
-        return sun.security.krb5.internal.ktab.KeyTab.getInstance(file);
+        try {
+            return sun.security.krb5.internal.ktab.KeyTab.getInstance(file);
+        } catch (AccessControlException ace) {
+            if (file != null) {
+                // It's OK to show the name if caller specified it
+                throw ace;
+            } else {
+                AccessControlException ace2 = new AccessControlException(
+                        "Access to default keytab denied (modified exception)");
+                ace2.setStackTrace(ace.getStackTrace());
+                throw ace2;
+            }
+        }
     }
 
     /**