8022410: Fix Javac Warnings in com.sun.security.auth Package
authordxu
Tue, 06 Aug 2013 14:33:56 -0700
changeset 19212 80526b520497
parent 19211 32a04c562026
child 19213 c360667a0da2
8022410: Fix Javac Warnings in com.sun.security.auth Package Reviewed-by: darcy
jdk/src/share/classes/com/sun/security/auth/PolicyFile.java
jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java
--- a/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java	Tue Aug 06 14:24:05 2013 -0700
+++ b/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java	Tue Aug 06 14:33:56 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,10 @@
 
 import sun.security.util.PropertyExpander;
 
+import sun.security.provider.PolicyParser.PrincipalEntry;
+import sun.security.provider.PolicyParser.GrantEntry;
+import sun.security.provider.PolicyParser.PermissionEntry;
+
 /**
  * This class represents a default implementation for
  * <code>javax.security.auth.Policy</code>.
@@ -469,7 +473,8 @@
      * @param policyFile the policy Reader object.
      */
     private void init(URL policy) {
-        PolicyParser pp = new PolicyParser(expandProperties);
+        sun.security.provider.PolicyParser pp =
+                new sun.security.provider.PolicyParser(expandProperties);
         try {
             InputStreamReader isr
                 = new InputStreamReader(getInputStream(policy));
@@ -477,12 +482,12 @@
             isr.close();
             KeyStore keyStore = initKeyStore(policy, pp.getKeyStoreUrl(),
                                              pp.getKeyStoreType());
-            Enumeration<PolicyParser.GrantEntry> enum_ = pp.grantElements();
+            Enumeration<GrantEntry> enum_ = pp.grantElements();
             while (enum_.hasMoreElements()) {
-                PolicyParser.GrantEntry ge = enum_.nextElement();
+                GrantEntry ge = enum_.nextElement();
                 addGrantEntry(ge, keyStore);
             }
-        } catch (PolicyParser.ParsingException pe) {
+        } catch (sun.security.provider.PolicyParser.ParsingException pe) {
             System.err.println(AUTH_POLICY +
                                 rb.getString(".error.parsing.") + policy);
             System.err.println(AUTH_POLICY +
@@ -521,8 +526,8 @@
      *
      * @return null if signedBy alias is not recognized
      */
-    CodeSource getCodeSource(PolicyParser.GrantEntry ge, KeyStore keyStore)
-        throws java.net.MalformedURLException
+    CodeSource getCodeSource(GrantEntry ge, KeyStore keyStore)
+            throws java.net.MalformedURLException
     {
         Certificate[] certs = null;
         if (ge.signedBy != null) {
@@ -559,20 +564,18 @@
     /**
      * Add one policy entry to the vector.
      */
-    private void addGrantEntry(PolicyParser.GrantEntry ge,
-                               KeyStore keyStore) {
+    private void addGrantEntry(GrantEntry ge, KeyStore keyStore) {
 
         if (debug != null) {
             debug.println("Adding policy entry: ");
             debug.println("  signedBy " + ge.signedBy);
             debug.println("  codeBase " + ge.codeBase);
             if (ge.principals != null && ge.principals.size() > 0) {
-                ListIterator<PolicyParser.PrincipalEntry> li =
-                                                ge.principals.listIterator();
+                ListIterator<PrincipalEntry> li = ge.principals.listIterator();
                 while (li.hasNext()) {
-                    PolicyParser.PrincipalEntry pppe = li.next();
-                    debug.println("  " + pppe.principalClass +
-                                        " " + pppe.principalName);
+                    PrincipalEntry pppe = li.next();
+                    debug.println("  " + pppe.getPrincipalClass() +
+                                        " " + pppe.getPrincipalName());
                 }
             }
             debug.println();
@@ -584,10 +587,9 @@
             if (codesource == null) return;
 
             PolicyEntry entry = new PolicyEntry(codesource);
-            Enumeration<PolicyParser.PermissionEntry> enum_ =
-                                                ge.permissionElements();
+            Enumeration<PermissionEntry> enum_ = ge.permissionElements();
             while (enum_.hasMoreElements()) {
-                PolicyParser.PermissionEntry pe = enum_.nextElement();
+                PermissionEntry pe = enum_.nextElement();
                 try {
                     // XXX special case PrivateCredentialPermission-SELF
                     Permission perm;
@@ -998,11 +1000,11 @@
                 return true;
             }
 
-            ListIterator<PolicyParser.PrincipalEntry> pli =
-                                        scs.getPrincipals().listIterator();
+            ListIterator<PrincipalEntry> pli =
+                    scs.getPrincipals().listIterator();
             while (pli.hasNext()) {
 
-                PolicyParser.PrincipalEntry principal = pli.next();
+                PrincipalEntry principal = pli.next();
 
                 // XXX
                 //      if the Policy entry's Principal does not contain a
@@ -1050,30 +1052,29 @@
      *                  if (y == 1), it's the principal name.
      */
     private String[][] getPrincipalInfo
-                (PolicyParser.PrincipalEntry principal,
-                final CodeSource accCs) {
+                (PrincipalEntry principal, final CodeSource accCs) {
 
         // there are 3 possibilities:
         // 1) the entry's Principal class and name are not wildcarded
         // 2) the entry's Principal name is wildcarded only
         // 3) the entry's Principal class and name are wildcarded
 
-        if (!principal.principalClass.equals
-                (PolicyParser.PrincipalEntry.WILDCARD_CLASS) &&
-            !principal.principalName.equals
-                (PolicyParser.PrincipalEntry.WILDCARD_NAME)) {
+        if (!principal.getPrincipalClass().equals
+                (PrincipalEntry.WILDCARD_CLASS) &&
+            !principal.getPrincipalName().equals
+                (PrincipalEntry.WILDCARD_NAME)) {
 
             // build a PrivateCredentialPermission for the principal
             // from the Policy entry
             String[][] info = new String[1][2];
-            info[0][0] = principal.principalClass;
-            info[0][1] = principal.principalName;
+            info[0][0] = principal.getPrincipalClass();
+            info[0][1] = principal.getPrincipalName();
             return info;
 
-        } else if (!principal.principalClass.equals
-                (PolicyParser.PrincipalEntry.WILDCARD_CLASS) &&
-            principal.principalName.equals
-                (PolicyParser.PrincipalEntry.WILDCARD_NAME)) {
+        } else if (!principal.getPrincipalClass().equals
+                (PrincipalEntry.WILDCARD_CLASS) &&
+            principal.getPrincipalName().equals
+                (PrincipalEntry.WILDCARD_NAME)) {
 
             // build a PrivateCredentialPermission for all
             // the Subject's principals that are instances of principalClass
@@ -1088,7 +1089,7 @@
                 // If it doesn't, we should stop here with a ClassCastException.
                 @SuppressWarnings("unchecked")
                 Class<? extends Principal> pClass = (Class<? extends Principal>)
-                        Class.forName(principal.principalClass, false,
+                        Class.forName(principal.getPrincipalClass(), false,
                                       ClassLoader.getSystemClassLoader());
                 principalSet = scs.getSubject().getPrincipals(pClass);
             } catch (Exception e) {
@@ -1387,6 +1388,7 @@
     }
 }
 
+@SuppressWarnings("deprecation")
 class PolicyPermissions extends PermissionCollection {
 
     private static final long serialVersionUID = -1954188373270545523L;
--- a/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java	Tue Aug 06 14:24:05 2013 -0700
+++ b/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java	Tue Aug 06 14:33:56 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import java.lang.reflect.Constructor;
 
 import javax.security.auth.Subject;
+import sun.security.provider.PolicyParser.PrincipalEntry;
 
 /**
  * <p> This <code>SubjectCodeSource</code> class contains
@@ -57,7 +58,7 @@
         });
 
     private Subject subject;
-    private LinkedList<PolicyParser.PrincipalEntry> principals;
+    private LinkedList<PrincipalEntry> principals;
     private static final Class[] PARAMS = { String.class };
     private static final sun.security.util.Debug debug =
         sun.security.util.Debug.getInstance("auth", "\t[Auth Access]");
@@ -87,14 +88,14 @@
      *                  <code>SubjectCodeSource</code> <p>
      */
     SubjectCodeSource(Subject subject,
-        LinkedList<PolicyParser.PrincipalEntry> principals,
+        LinkedList<PrincipalEntry> principals,
         URL url, Certificate[] certs) {
 
         super(url, certs);
         this.subject = subject;
         this.principals = (principals == null ?
-                new LinkedList<PolicyParser.PrincipalEntry>() :
-                new LinkedList<PolicyParser.PrincipalEntry>(principals));
+                new LinkedList<PrincipalEntry>() :
+                new LinkedList<PrincipalEntry>(principals));
         sysClassLoader = java.security.AccessController.doPrivileged
         (new java.security.PrivilegedAction<ClassLoader>() {
             public ClassLoader run() {
@@ -114,7 +115,7 @@
      *          <code>SubjectCodeSource</code> as a <code>LinkedList</code>
      *          of <code>PolicyParser.PrincipalEntry</code> objects.
      */
-    LinkedList<PolicyParser.PrincipalEntry> getPrincipals() {
+    LinkedList<PrincipalEntry> getPrincipals() {
         return principals;
     }
 
@@ -167,7 +168,7 @@
      */
     public boolean implies(CodeSource codesource) {
 
-        LinkedList<PolicyParser.PrincipalEntry> subjectList = null;
+        LinkedList<PrincipalEntry> subjectList = null;
 
         if (codesource == null ||
             !(codesource instanceof SubjectCodeSource) ||
@@ -197,20 +198,19 @@
             return false;
         }
 
-        ListIterator<PolicyParser.PrincipalEntry> li =
-                this.principals.listIterator(0);
+        ListIterator<PrincipalEntry> li = this.principals.listIterator(0);
         while (li.hasNext()) {
-            PolicyParser.PrincipalEntry pppe = li.next();
+            PrincipalEntry pppe = li.next();
             try {
 
                 // handle PrincipalComparators
 
                 Class<?> principalComparator = Class.forName(
-                        pppe.principalClass, true, sysClassLoader);
+                        pppe.getPrincipalClass(), true, sysClassLoader);
                 Constructor<?> c = principalComparator.getConstructor(PARAMS);
                 PrincipalComparator pc =
                         (PrincipalComparator)c.newInstance
-                        (new Object[] { pppe.principalName });
+                        (new Object[] { pppe.getPrincipalName() });
 
                 if (!pc.implies(that.getSubject())) {
                     if (debug != null)
@@ -236,11 +236,10 @@
                     Iterator<Principal> i =
                                 that.getSubject().getPrincipals().iterator();
 
-                    subjectList = new LinkedList<PolicyParser.PrincipalEntry>();
+                    subjectList = new LinkedList<PrincipalEntry>();
                     while (i.hasNext()) {
                         Principal p = i.next();
-                        PolicyParser.PrincipalEntry spppe =
-                                new PolicyParser.PrincipalEntry
+                        PrincipalEntry spppe = new PrincipalEntry
                                 (p.getClass().getName(), p.getName());
                         subjectList.add(spppe);
                     }
@@ -281,23 +280,19 @@
      *          <i>pppe</i> argument.
      */
     private boolean subjectListImpliesPrincipalEntry(
-                LinkedList<PolicyParser.PrincipalEntry> subjectList,
-                PolicyParser.PrincipalEntry pppe) {
+                LinkedList<PrincipalEntry> subjectList, PrincipalEntry pppe) {
 
-        ListIterator<PolicyParser.PrincipalEntry> li =
-                                        subjectList.listIterator(0);
+        ListIterator<PrincipalEntry> li = subjectList.listIterator(0);
         while (li.hasNext()) {
-            PolicyParser.PrincipalEntry listPppe = li.next();
+            PrincipalEntry listPppe = li.next();
 
-            if (pppe.principalClass.equals
-                        (PolicyParser.PrincipalEntry.WILDCARD_CLASS) ||
-                pppe.principalClass.equals
-                        (listPppe.principalClass)) {
-
-                if (pppe.principalName.equals
-                        (PolicyParser.PrincipalEntry.WILDCARD_NAME) ||
-                    pppe.principalName.equals
-                        (listPppe.principalName))
+            if (pppe.getPrincipalClass().equals
+                        (PrincipalEntry.WILDCARD_CLASS) ||
+                pppe.getPrincipalClass().equals(listPppe.getPrincipalClass()))
+            {
+                if (pppe.getPrincipalName().equals
+                        (PrincipalEntry.WILDCARD_NAME) ||
+                    pppe.getPrincipalName().equals(listPppe.getPrincipalName()))
                     return true;
             }
         }
@@ -390,13 +385,12 @@
             }
         }
         if (principals != null) {
-            ListIterator<PolicyParser.PrincipalEntry> li =
-                                        principals.listIterator();
+            ListIterator<PrincipalEntry> li = principals.listIterator();
             while (li.hasNext()) {
-                PolicyParser.PrincipalEntry pppe = li.next();
+                PrincipalEntry pppe = li.next();
                 returnMe = returnMe + rb.getString("NEWLINE") +
-                        pppe.principalClass + " " +
-                        pppe.principalName;
+                        pppe.getPrincipalClass() + " " +
+                        pppe.getPrincipalName();
             }
         }
         return returnMe;