changeset 201:d2a298618ab8

8132465: DeviceManager.open(null, GPIOPin.class) does not throw SecurityException (all permissions implied by '*.*', DeviceMgmtPermission.OPEN are denied) Summary: Changed time of permission verification and permission resource name Reviewed-by: alkonsta
author snazarki
date Tue, 28 Jul 2015 18:08:58 +0300
parents 1cc45ae786e5
children 93cb2dd1d0e0
files src/share/classes/jdk/dio/DeviceManager.java
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/jdk/dio/DeviceManager.java	Tue Jul 28 18:01:53 2015 +0300
+++ b/src/share/classes/jdk/dio/DeviceManager.java	Tue Jul 28 18:08:58 2015 +0300
@@ -464,6 +464,12 @@
         UnsupportedDeviceTypeException, DeviceNotFoundException, UnavailableDeviceException,
         UnsupportedAccessModeException {
         checkID(id);
+
+        do {
+            AccessController.checkPermission(new DeviceMgmtPermission(":" + id, DeviceMgmtPermission.OPEN));
+        } while (false);
+
+
         checkMode(mode);
         if (null == intf) {
             throw new NullPointerException(
@@ -483,11 +489,6 @@
             );
         }
 
-        do {
-            String name = (null == descr.getName()) ? ":" + id : descr.getName() + ":" + id;
-            AccessController.checkPermission(new DeviceMgmtPermission(name, DeviceMgmtPermission.OPEN));
-        } while (false);
-
         try {
             final PeripheralFactory<P> f = getFactory(descr.getInterface());
             final DeviceDescriptor<P> fdescr = descr;
@@ -715,6 +716,12 @@
                 ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_NAME_AND_PROPERTIES)
             );
         }
+
+        do {
+            AccessController.checkPermission(new DeviceMgmtPermission((null == name)? "" : name, DeviceMgmtPermission.OPEN));
+        } while (false);
+
+
         if (null == intf) {
             throw new NullPointerException(
                 ExceptionMessage.format(ExceptionMessage.DEVICE_NULL_INTF)
@@ -734,12 +741,6 @@
         while (iter.hasNext()) {
             DeviceDescriptor<P> descr = iter.next();
             try {
-                do {
-                    String perm =  (null == descr.getName()) ? "" : descr.getName();
-                    perm = (UNSPECIFIED_ID == descr.getID()) ? perm : perm + ":" + descr.getID();
-                    AccessController.checkPermission(new DeviceMgmtPermission(name, DeviceMgmtPermission.OPEN));
-                } while (false);
-
                 final PeripheralFactory<P> f =  getFactory(descr.getInterface());
 
                 final DeviceDescriptor<P> fdescr = descr;