changeset 57:7531895ef161

8065384: DIO permission action verification redesign Summary: Remove dependency of ActionFactory from DevicePermission classes to make different device modules conditionally compiled. Reviewed-by: snazarki Contributed-by: alexey.mironov@oracle.com
author snazarki
date Wed, 03 Dec 2014 21:57:39 +0400
parents 958ec7f4180f
children 4ab1a1b60e6c
files src/se/classes/jdk/dio/mmio/MMIOPermission.java src/share/classes/com/oracle/dio/utils/ActionFactory.java src/share/classes/jdk/dio/DeviceMgmtPermission.java src/share/classes/jdk/dio/DevicePermission.java src/share/classes/jdk/dio/adc/ADCPermission.java src/share/classes/jdk/dio/atcmd/ATPermission.java src/share/classes/jdk/dio/counter/CounterPermission.java src/share/classes/jdk/dio/dac/DACPermission.java src/share/classes/jdk/dio/generic/GenericPermission.java src/share/classes/jdk/dio/gpio/GPIOPinPermission.java src/share/classes/jdk/dio/gpio/GPIOPortPermission.java src/share/classes/jdk/dio/i2cbus/I2CPermission.java src/share/classes/jdk/dio/pwm/PWMPermission.java src/share/classes/jdk/dio/spibus/SPIPermission.java src/share/classes/jdk/dio/uart/UARTPermission.java src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java
diffstat 16 files changed, 130 insertions(+), 226 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/jdk/dio/mmio/MMIOPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/se/classes/jdk/dio/mmio/MMIOPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -88,81 +88,6 @@
      * @see #getName getName
      */
     public MMIOPermission(String name, String actions) {
-        super(name);
-    }
-
-    /**
-     * Checks two {@code MMIOPermission} objects for equality.
-     *
-     * @param obj
-     *            the object to test for equality with this object.
-     *
-     * @return {@code true} if {@code obj} is a {@code MMIOPermission} and has the same target name and actions as
-     *         this {@code MMIOPermission} object.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        return false;
-    }
-
-    /**
-     * Returns the list of possible actions in the following order: {@code open} or {@code powermanage}. </em>
-     *
-     * @return comma-separated list of possible actions.
-     */
-    @Override
-    public String getActions() {
-        return null;
-    }
-
-    /**
-     * Returns the hash code value for this object.
-     *
-     * @return a hash code value for this object.
-     */
-    @Override
-    public int hashCode() {
-        return 0;
-    }
-
-    /**
-     * Checks if this {@code MMIOPermission} object "implies" the specified permission.
-     * <p />
-     * More specifically, this method returns {@code true} if:
-     * <ul>
-     * <li>{@code permission} is an instance of {@code MMIOPermission}, and
-     * <li>{@code permission}'s actions are a proper subset of this object's action list, and</i>
-     * <li>{@code permission}'s hardware addressing information or range thereof
-     * is included in this {@code MMIOPermission}'s hardware addressing information range.
-     * </ul>
-     *
-     * @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.
-     */
-    @Override
-    public boolean implies(Permission permission) {
-        return false;
-    }
-
-    /**
-     * Returns a new {@code PermissionCollection} for storing {@code MMIOPermission} objects.
-     * <p>
-     * {@code MMIOPermission} objects must be stored in a manner that allows them to be inserted into the collection in
-     * any order, but that also enables the {@code PermissionCollection} implies method to be implemented in an
-     * efficient (and consistent) manner.
-     *
-     * <p>
-     * If {@code null} is returned, then the caller of this method is free to store permissions of this type in any
-     * PermissionCollection they choose (one that uses a {@code Hashtable}, one that uses a {@code Vector}, etc).
-     *
-     * @return a new {@code PermissionCollection} suitable for storing {@code MMIOPermission} objects, or {@code null}
-     *         if one is not defined.
-     */
-    @Override
-    public PermissionCollection newPermissionCollection() {
-        return null;
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
 }
--- a/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Wed Dec 03 21:57:39 2014 +0400
@@ -25,149 +25,124 @@
 
 package com.oracle.dio.utils;
 
-import java.security.Permission;
+import java.util.StringTokenizer;
 import jdk.dio.DevicePermission;
-import jdk.dio.DeviceMgmtPermission;
-import jdk.dio.atcmd.ATPermission;
-import jdk.dio.gpio.GPIOPinPermission;
-import jdk.dio.gpio.GPIOPortPermission;
 
 /**
  * Utility class for device permission class
  */
 public class ActionFactory {
     /**
-     * Return true if all actions are applied for permission
+     * Checks if <code>actions1</code> list "implies"
+     * <code>actions2</code> list
      *
-     * @param actions for validation
-     * @param permission to verify which action implied
+     * @param actions1 comma-separated list of verified and valid
+     *                 actions
+     * @param actions1 comma-separated list of verified and valid
+     *                 actions
      *
-     * @return true for valid
+     * @return true <code>actions2</code> list is implied by
+     *         <code>actions1</code> list
      */
-    public static boolean actionImplies(String actions, Permission permission) {
-        int index = actions.indexOf(",");
+    public static boolean implies(String actions1, String actions2) {
+        int index = actions2.indexOf(",");
         if (index == -1) {
-            return isValidAction(actions, permission) && (permission.getActions().indexOf(actions) != -1);
+            return isIncluded(actions2, actions1);
         } else {
-            return actionImplies(actions.substring(0, index), permission) &&
-                   actionImplies(actions.substring(index+1), permission);
+            return implies(actions1, actions2.substring(0, index)) &&
+                   implies(actions1, actions2.substring(index+1));
         }
     }
 
     /**
+     * Checks if given <code>what</code> is included to
+     * <code>where</code> list
+     *
+     * @param what   string to compare
+     * @param where  coma-separated string list to search at
+     *
+     * @return <code>true</code> if <code>what</code> contains in
+     *         the list
+     */
+    private static boolean isIncluded(String what, String where) {
+        StringTokenizer tokens = new StringTokenizer(where, ",");
+        while (tokens.hasMoreElements()) {
+            if (tokens.nextToken().equals(what)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Return true for permission specified actions
      *
      * @param action for validation
-     * @param permission to verify which action implied
+     * @param normalizedList allowed actions list
      *
      * @return true for valid
      */
-    private static boolean isValidAction(String action, Permission permission) {
-        if (permission instanceof DevicePermission) {
-            if (DevicePermission.OPEN.equals(action)) return true;
-            if (DevicePermission.POWER_MANAGE.equals(action)) return true;
+    private static boolean isValidAction(String actions, String normalizedList) {
+        StringTokenizer tokez = new StringTokenizer(actions, ",");
+        while (tokez.hasMoreElements()) {
+            String action = tokez.nextToken();
+            if (!isIncluded(action, normalizedList)) {
+                return false;
+            }
         }
-        if (permission instanceof DeviceMgmtPermission) {
-            if (DeviceMgmtPermission.REGISTER.equals(action)) return true;
-            if (DeviceMgmtPermission.UNREGISTER.equals(action)) return true;
-            if (DeviceMgmtPermission.OPEN.equals(action)) return true;
-        }
-        if (permission instanceof ATPermission)
-            if (ATPermission.DATA.equals(action)) return true;
-        if (permission instanceof GPIOPinPermission)
-            if (GPIOPinPermission.SET_DIRECTION.equals(action)) return true;
-        if (permission instanceof GPIOPortPermission)
-            if (GPIOPortPermission.SET_DIRECTION.equals(action)) return true;
-
-        return false;
+        return true;
     }
 
     /**
      * Returns action list in spec required order
-     * <p>
-     * It is assumed that actions have the following priority
-     * <ul>
-     *     <li> open </li>
-     *     <li> powermanage </li>
-     *     <li> other peripheral specific actions </li>
-     * </ul>
      *
-     * @param actions unordered and {@code verified} list
-     * @param permission to verify which action implied
+     * @param actions unordered and unverified list
+     * @param normalizedList allowed actions list in normalized form
      *
      * @return ordered list
      */
-    public static String verifyAndOrderActions(String actions, Permission permission) {
-        int idx = 0;
-        int prevIdx = 0;
-        while (-1 != (idx = actions.indexOf(',', prevIdx))) {
-            String s1 = actions.substring(prevIdx, idx);
-            // check for duplicate and validity
-            if (!isValidAction(s1, permission) || -1 != actions.indexOf(s1, idx)) {
-                throw new IllegalArgumentException(actions);
-            }
-            prevIdx = idx + 1;
+    public static String verifyAndOrderActions(String actions, String normalizedList) {
+        if(actions == null){
+            throw new IllegalArgumentException(
+                ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
+            );
         }
-        if (!isValidAction(actions.substring(prevIdx), permission) ) {
-                throw new IllegalArgumentException(actions);
+        if(actions.length() == 0){
+            throw new IllegalArgumentException(
+                ExceptionMessage.format(ExceptionMessage.DEVICE_EMPTY_ACTIONS)
+            );
         }
 
+        if (!isValidAction(actions, normalizedList)) {
+            throw new IllegalArgumentException(actions);
+        }
+
+        boolean comma = false;
         StringBuilder sb = new StringBuilder(30);
-        if (permission instanceof DeviceMgmtPermission) {
-            if (-1 != actions.indexOf(DeviceMgmtPermission.REGISTER)) {
-                sb.append(DeviceMgmtPermission.REGISTER);
-                idx = 1;
-            }
-            if (-1 != actions.indexOf(DeviceMgmtPermission.UNREGISTER)) {
-                if (idx > 0 ) {
+        StringTokenizer tokez = new StringTokenizer(normalizedList, ",");
+        while (tokez.hasMoreElements()) {
+            String validAction = tokez.nextToken();
+            if (isIncluded(validAction, actions)) {
+                if (comma) {
                     sb.append(',');
                 }
-                sb.append(DeviceMgmtPermission.UNREGISTER);
-                idx = 1;
-            }
-
-            if (-1 != actions.indexOf(DeviceMgmtPermission.OPEN)) {
-                if (idx > 0 ) {
-                    sb.append(',');
-                }
-                sb.append(DeviceMgmtPermission.OPEN);
-                idx = 1;
+                sb.append(validAction);
+                comma = true;
             }
         }
-        if (permission instanceof DevicePermission) {
-            if (-1 != actions.indexOf(DevicePermission.OPEN)) {
-                sb.append(DevicePermission.OPEN);
-                idx = 1;
-            }
-            if (-1 != actions.indexOf(DevicePermission.POWER_MANAGE)) {
-                if (idx > 0 ) {
-                    sb.append(',');
-                }
-                sb.append(DevicePermission.POWER_MANAGE);
-                idx = 1;
-            }
-        }
-        if ((permission instanceof ATPermission) && -1 != actions.indexOf(ATPermission.DATA)) {
-            if (idx > 0 ) {
-                sb.append(',');
-            }
-            sb.append(ATPermission.DATA);
-            idx = 1;
-        }
-        if ((permission instanceof GPIOPinPermission) && -1 != actions.indexOf(GPIOPinPermission.SET_DIRECTION)) {
-            if (idx > 0 ) {
-                sb.append(',');
-            }
-            sb.append(GPIOPinPermission.SET_DIRECTION);
-            idx = 1;
-        }
-        if ((permission instanceof GPIOPortPermission) && -1 != actions.indexOf(GPIOPortPermission.SET_DIRECTION)) {
-            if (idx > 0 ) {
-                sb.append(',');
-            }
-            sb.append(GPIOPortPermission.SET_DIRECTION);
-            idx = 1;
-        }
+
         return sb.toString();
     }
-}
\ No newline at end of file
+
+    /**
+     * Verifies and order given <code>actions</code> against
+     * DevicePermission actions list
+     *
+     * @param actions unordered and unverified list
+     *
+     * @return ordered and verified list
+     */
+    public static String verifyAndOrderDeviceActions(String actions) {
+        return verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE);
+    }
+}
--- a/src/share/classes/jdk/dio/DeviceMgmtPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/DeviceMgmtPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -30,6 +30,7 @@
 import com.oracle.dio.utils.ActionFactory;
 import java.util.Vector;
 import com.oracle.dio.utils.ExceptionMessage;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code DeviceMgmtPermission} class defines permissions for registering and unregistering devices as
@@ -106,7 +107,7 @@
      */
     public static final String OPEN = "open";
 
-    /** Comma-delimited ordered action list */
+    /** Comma-separated ordered action list */
     private String myActions;
 
     /**
@@ -130,7 +131,7 @@
                 ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
             );
         }
-        myActions = ActionFactory.verifyAndOrderActions(actions, this);
+        myActions = ActionFactory.verifyAndOrderActions(actions, REGISTER+","+UNREGISTER+","+OPEN);
     }
 
     /**
@@ -165,7 +166,7 @@
      */
     @Override
     public int hashCode() {
-        return getName().hashCode();
+        return (getName() + myActions).hashCode();
     }
 
     /**
@@ -190,7 +191,7 @@
         if ((permission == null) || (permission.getClass() != getClass()))
             return false;
 
-        if (!ActionFactory.actionImplies(permission.getActions(), this)) return false;
+        if (!ActionFactory.implies(myActions, permission.getActions())) return false;
 
         int idx = 0;
         String name = permission.getName();
--- a/src/share/classes/jdk/dio/DevicePermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/DevicePermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -96,6 +96,7 @@
  * @since 1.0
  */
 public abstract class DevicePermission extends Permission {
+
     /**
      * The {@code open} action.
      */
@@ -107,7 +108,7 @@
     public static final String POWER_MANAGE = "powermanage";
 
     /**
-     * Comam-separated action list
+     * Coma-separated action list
      *
      */
     private String myActions;
@@ -155,18 +156,7 @@
      */
     public DevicePermission(String name, String actions) {
         super(checkName(name));
-        if(actions == null){
-            throw new IllegalArgumentException(
-                ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_ACTIONS)
-            );
-        }
-        if(actions.length() == 0){
-            throw new IllegalArgumentException(
-                ExceptionMessage.format(ExceptionMessage.DEVICE_EMPTY_ACTIONS)
-            );
-        }
-
-        myActions = ActionFactory.verifyAndOrderActions(actions, this);
+        myActions = actions;
     }
 
     /**
@@ -209,7 +199,7 @@
      * Returns the list of possible actions in the following order: {@code open} or
      * {@code powermanage} (additional actions may be defined by subclasses).
      *
-     * @return comma-delimited list of possible actions.
+     * @return comma-separated list of possible actions.
      */
     @Override
     public String getActions() {
@@ -223,7 +213,7 @@
      */
     @Override
     public int hashCode() {
-        return getName().hashCode();
+        return (getName() + myActions).hashCode();
     }
 
 
@@ -249,7 +239,7 @@
         if ((permission == null) || (permission.getClass() != getClass()))
             return false;
 
-        if (!ActionFactory.actionImplies(permission.getActions(), this)) return false;
+        if (!ActionFactory.implies(myActions, permission.getActions())) return false;
 
         int idx = 0;
         String name = permission.getName();
@@ -336,16 +326,24 @@
      */
     @Override
     public PermissionCollection newPermissionCollection() {
-        return new PeripheralPermissionCollection();
+        return new PeripheralPermissionCollection(this.getClass());
     }
 }
 
 final class PeripheralPermissionCollection extends PermissionCollection {
 
     private final Vector<DevicePermission> permissions = new Vector<>(6);
+    /**
+     * The class to which all PeripheralPermissios in this
+     * PeripheralPermissionCollection belongs.*/
+    private final Class permClazz;
+
+    PeripheralPermissionCollection(Class clazz) {
+        permClazz = clazz;
+    }
 
     public boolean implies(Permission permission) {
-        if (! (permission instanceof DevicePermission)) {
+        if (!permClazz.isInstance(permission)) {
           return false;
         }
         DevicePermission perm = (DevicePermission) permission;
@@ -358,7 +356,7 @@
         return false;
     }
     public void add(Permission permission) {
-        if (! (permission instanceof DevicePermission))
+        if (!permClazz.isInstance(permission))
             throw new IllegalArgumentException(
                 ExceptionMessage.format(ExceptionMessage.DEVICE_INVALID_PERMISSION, permission)
             );
--- a/src/share/classes/jdk/dio/adc/ADCPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/adc/ADCPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code ADCPermission} class defines permissions for ADC channel access.
@@ -92,6 +93,6 @@
      * @see #getName getName
      */
     public ADCPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
 }
--- a/src/share/classes/jdk/dio/atcmd/ATPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/atcmd/ATPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code ATPermission} class defines permissions for AT device access.
@@ -97,6 +98,6 @@
      *             specified possible actions.
      */
     public ATPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DATA + "," + DevicePermission.POWER_MANAGE));
     }
 }
--- a/src/share/classes/jdk/dio/counter/CounterPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/counter/CounterPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code CounterPermission} class defines permissions for pulse counter access.
@@ -92,7 +93,7 @@
      * @see #getName getName
      */
     public CounterPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/dac/DACPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/dac/DACPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code DACPermission} class defines permissions for DAC channel access.
@@ -90,8 +91,6 @@
      * @see #getName getName
      */
     public DACPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }
-
--- a/src/share/classes/jdk/dio/generic/GenericPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/generic/GenericPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code GenericPermission} class defines permissions for g device access.
@@ -90,8 +91,7 @@
      * @see #getName getName
      */
     public GenericPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }
 
--- a/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/gpio/GPIOPinPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code GPIOPinPermission} class defines permissions for GPIO pin access.
@@ -89,7 +90,7 @@
      * @param name
      *            the target name (as defined above).
      * @param actions
-     *            comma-delimited list of device operations: {@code open}, {@code powermanage}
+     *            comma-separated list of device operations: {@code open}, {@code powermanage}
      *            or {@code setdirection}.
      * @throws NullPointerException
      *             if {@code name} is {@code null}.
@@ -99,6 +100,6 @@
      * @see #getName getName
      */
     public GPIOPinPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
     }
 }
--- a/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/gpio/GPIOPortPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code GPIOPortPermission} class defines permissions for GPIO port access.
@@ -97,6 +98,6 @@
      * @see #getName getName
      */
     public GPIOPortPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderActions(actions, DevicePermission.OPEN + "," + DevicePermission.POWER_MANAGE + "," + SET_DIRECTION));
     }
 }
--- a/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/i2cbus/I2CPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code I2CPermission} class defines permissions for I2C slave device access.
@@ -92,8 +93,6 @@
      * @see #getName getName
      */
     public I2CPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }
-
--- a/src/share/classes/jdk/dio/pwm/PWMPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/pwm/PWMPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code PWMPermission} class defines permissions for PWM channel access.
@@ -90,8 +91,7 @@
      * @see #getName getName
      */
     public PWMPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }
 
--- a/src/share/classes/jdk/dio/spibus/SPIPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/spibus/SPIPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code SPIPermission} class defines permissions for SPI slave device access.
@@ -90,7 +91,7 @@
      * @see #getName getName
      */
     public SPIPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
 }
 
--- a/src/share/classes/jdk/dio/uart/UARTPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/uart/UARTPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,8 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
+
 
 /**
  * The {@code UARTPermission} class defines permissions for UART channel access.
@@ -90,8 +92,7 @@
      * @see #getName getName
      */
     public UARTPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }
 
--- a/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Wed Dec 03 21:24:03 2014 +0400
+++ b/src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java	Wed Dec 03 21:57:39 2014 +0400
@@ -29,6 +29,7 @@
 import jdk.dio.DevicePermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
+import com.oracle.dio.utils.ActionFactory;
 
 /**
  * The {@code WatchdogTimerPermission} class defines permissions for watchdog timer access.
@@ -80,7 +81,7 @@
      * @param name
      *            the target name (as defined above).
      * @param actions
-     *            comma-delimited list of device operations: {@code open} or {@code powermanage}.
+     *            comma-separated list of device operations: {@code open} or {@code powermanage}.
      * @throws NullPointerException
      *             if {@code name} is {@code null}.
      * @throws IllegalArgumentException
@@ -90,8 +91,7 @@
      * @see #getName getName
      */
     public WatchdogTimerPermission(String name, String actions) {
-        super(name, actions);
+        super(name, ActionFactory.verifyAndOrderDeviceActions(actions));
     }
-
 }