Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java
          +++ new/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java
↓ open down ↓ 215 lines elided ↑ open up ↑
 216  216       * A ExecOptionPermissionCollection handles comparing a permission like
 217  217       * "a.b.c.d.e" * with a Permission such as "a.b.*", or "*".
 218  218       *
 219  219       * @serial include
 220  220       */
 221  221      private static class ExecOptionPermissionCollection
 222  222          extends PermissionCollection
 223  223          implements java.io.Serializable
 224  224      {
 225  225  
 226      -        private Hashtable permissions;
      226 +        private Hashtable<String, Permission> permissions;
 227  227          private boolean all_allowed; // true if "*" is in the collection
 228  228          private static final long serialVersionUID = -1242475729790124375L;
 229  229  
 230  230          /**
 231  231           * Create an empty ExecOptionPermissionCollection.
 232  232           */
 233  233          public ExecOptionPermissionCollection() {
 234      -            permissions = new Hashtable(11);
      234 +            permissions = new Hashtable<String, Permission>(11);
 235  235              all_allowed = false;
 236  236          }
 237  237  
 238  238          /**
 239  239           * Adds a permission to the collection. The key for the hash is
 240  240           * permission.name.
 241  241           *
 242  242           * @param permission the Permission object to add.
 243  243           *
 244  244           * @exception IllegalArgumentException - if the permission is not a
↓ open down ↓ 39 lines elided ↑ open up ↑
 284  284              // short circuit if the "*" Permission was added
 285  285              if (all_allowed)
 286  286                  return true;
 287  287  
 288  288              // strategy:
 289  289              // Check for full match first. Then work our way up the
 290  290              // name looking for matches on a.b.*
 291  291  
 292  292              String pname = p.getName();
 293  293  
 294      -            Permission x = (Permission) permissions.get(pname);
      294 +            Permission x = permissions.get(pname);
 295  295  
 296  296              if (x != null)
 297  297                  // we have a direct hit!
 298  298                  return x.implies(permission);
 299  299  
 300  300  
 301  301              // work our way up the tree...
 302  302              int last, offset;
 303  303  
 304  304              offset = pname.length() - 1;
 305  305  
 306  306              while ((last = pname.lastIndexOf(".", offset)) != -1) {
 307  307  
 308  308                  pname = pname.substring(0, last+1) + "*";
 309      -                x = (Permission) permissions.get(pname);
      309 +                x = permissions.get(pname);
 310  310  
 311  311                  if (x != null) {
 312  312                      return x.implies(permission);
 313  313                  }
 314  314                  offset = last - 1;
 315  315              }
 316  316  
 317  317              // check for "=*" wildcard match
 318  318              pname = p.getName();
 319  319              offset = pname.length() - 1;
 320  320  
 321  321              while ((last = pname.lastIndexOf("=", offset)) != -1) {
 322  322  
 323  323                  pname = pname.substring(0, last+1) + "*";
 324      -                x = (Permission) permissions.get(pname);
      324 +                x = permissions.get(pname);
 325  325  
 326  326                  if (x != null) {
 327  327                      return x.implies(permission);
 328  328                  }
 329  329                  offset = last - 1;
 330  330              }
 331  331  
 332  332              // we don't have to check for "*" as it was already checked
 333  333              // at the top (all_allowed), so we just return false
 334  334              return false;
 335  335          }
 336  336  
 337  337          /**
 338  338           * Returns an enumeration of all the ExecOptionPermission objects in the
 339  339           * container.
 340  340           *
 341  341           * @return an enumeration of all the ExecOptionPermission objects.
 342  342           */
 343  343  
 344      -        public Enumeration elements()
      344 +        public Enumeration<Permission> elements()
 345  345          {
 346  346              return permissions.elements();
 347  347          }
 348  348      }
 349  349  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX