changeset 265:958f53876e01

8142489: Presence of ATPermission ... "...,data" or (GPIOPinPermission|GPIOPortPermission ... "...,setdirection" in java.security.policy results in IAE Summary: Fix IAE in GPIOPinPermission|GPIOPortPermission Reviewed-by: snazarki
author onazarkina
date Sun, 13 Dec 2015 18:44:33 +0300
parents 4a3ade651fcc
children 9e33128d2ca4
files src/share/classes/jdk/dio/DevicePermission.java
diffstat 1 files changed, 37 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/jdk/dio/DevicePermission.java	Thu Dec 10 12:41:37 2015 +0300
+++ b/src/share/classes/jdk/dio/DevicePermission.java	Sun Dec 13 18:44:33 2015 +0300
@@ -28,6 +28,7 @@
 import java.security.PermissionCollection;
 import java.util.Enumeration;
 import java.util.Vector;
+
 import com.oracle.dio.utils.ExceptionMessage;
 import com.oracle.dio.utils.Utils;
 import romizer.Local;
@@ -123,7 +124,7 @@
      */
     public static final String POWER_MANAGE = "powermanage";
 
-     /**
+    /**
      * Coma-separated action list     *
      */
     private String myActions;
@@ -139,19 +140,16 @@
      * and each occurrence of <code>{controller-number}</code> is represented in its canonical
      * decimal representation form (without leading zeros).
      *
-     * @param name
-     *            the target name (as defined above).
-     * @throws NullPointerException
-     *             if {@code name} is {@code null}.
-     * @throws IllegalArgumentException
-     *             if {@code name} is not properly formatted.
+     * @param name the target name (as defined above).
+     * @throws NullPointerException     if {@code name} is {@code null}.
+     * @throws IllegalArgumentException if {@code name} is not properly formatted.
      * @see #getName getName
      */
     public DevicePermission(String name) {
         // null check
         super(name.toString());
         String[] ret = Utils.parseDevicePermissionName(name);
-        thisDevice  = ret[0];
+        thisDevice = ret[0];
         thisChannel = ret[1];
         myActions = OPEN;
     }
@@ -163,19 +161,15 @@
      * and each occurrence of <code>{controller-number}</code> is represented in its canonical
      * decimal representation form (without leading zeros).
      *
-     * @param name
-     *            the target name (as defined above).
-     * @param actions
-     *            comma-separated list of device operations: {@code open} or {@code powermanage}
-     *            (additional actions may be defined by subclasses).
-     * @throws NullPointerException
-     *             if {@code name} is {@code null}.
-     * @throws IllegalArgumentException
-     *             <ul>
-     *             <li>if {@code actions} is {@code null}, empty or contains an action other than the
-     *             specified possible actions,</li>
-     *             <li>if {@code name} is not properly formatted.</li>
-     *             </ul>
+     * @param name    the target name (as defined above).
+     * @param actions comma-separated list of device operations: {@code open} or {@code powermanage}
+     *                (additional actions may be defined by subclasses).
+     * @throws NullPointerException     if {@code name} is {@code null}.
+     * @throws IllegalArgumentException <ul>
+     *                                  <li>if {@code actions} is {@code null}, empty or contains an action other than the
+     *                                  specified possible actions,</li>
+     *                                  <li>if {@code name} is not properly formatted.</li>
+     *                                  </ul>
      * @see #getName getName
      */
     public DevicePermission(String name, String actions) {
@@ -183,11 +177,11 @@
         super(name.toString());
         if (null == actions) {
             throw new IllegalArgumentException(
-                ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
+                    ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
             );
         }
         String[] ret = Utils.parseDevicePermissionName(name);
-        thisDevice  = ret[0];
+        thisDevice = ret[0];
         thisChannel = ret[1];
         myActions = Utils.verifyAndOrderDeviceActions(actions);
     }
@@ -197,10 +191,9 @@
      * Checks that {@code obj}'s class is the same as this object's class and has the
      * same name (as returned by {@link Permission#getName Permission.getName}) and same actions (sorted as per {@link #getActions getActions}) as this object.
      *
-     * @param obj
-     *         the object to test for equality with this object.
+     * @param obj the object to test for equality with this object.
      * @return {@code true} if {@code obj}'s class is the same as this object's class and has the same target
-     *         name and actions as this object; {@code false} otherwise.
+     * name and actions as this object; {@code false} otherwise.
      */
     @Override
     public boolean equals(Object obj) {
@@ -213,7 +206,6 @@
      *
      * @param obj1 First object to compare
      * @param obj2 Second object to compare
-     *
      * @return {@code true} if objects are equals, {@code false} otherwise
      */
     static boolean equals(Object obj1, Object obj2) {
@@ -271,10 +263,9 @@
      * by the exact same a channel specification string or by the asterisk ({@code "*"}).</li>
      * </ul>
      *
-     * @param permission
-     *            the permission to check against.
+     * @param permission the permission to check against.
      * @return {@code true} if the specified permission is not {@code null} and is implied by this
-     *         object, {@code false} otherwise.
+     * object, {@code false} otherwise.
      */
     @Override
     public boolean implies(Permission permission) {
@@ -367,11 +358,26 @@
 }
 
 final class LocalPermission extends DevicePermission {
+    /**
+     * Comma-separated actions list
+     */
+    private String myActions;
+
+    LocalPermission(String name) {
+        super(name);
+        myActions = OPEN;
+    }
 
     LocalPermission(String name, String actionsList) {
-        super(name, actionsList);
+        //super(name, actionsList);
+        super(name);
+        myActions = Utils.verifyAndOrderActions(actionsList, DevicePermission.OPEN + ",data," + DevicePermission.POWER_MANAGE + ",setdirection");
     }
 
+    @Override
+    public String getActions() {
+        return myActions;
+    }
 }
 
 final class PeripheralPermissionCollection extends PermissionCollection {