1 7 package org.jboss.test; 8 9 import java.security.BasicPermission ; 10 import java.security.Permission ; 11 import java.security.PermissionCollection ; 12 import javax.naming.Name ; 13 14 19 public class NamespacePermission extends BasicPermission 20 { 21 private PermissionName fullName; 22 private String actions; 23 24 25 public NamespacePermission(String name, String actions) 26 { 27 super(name, actions); 28 this.actions = actions; 29 fullName = new PermissionName(name); 30 } 31 public NamespacePermission(Name name, String actions) 32 { 33 super(name.toString(), actions); 34 this.actions = actions; 35 fullName = new PermissionName(name); 36 } 37 38 public String getActions() 39 { 40 return actions; 41 } 42 43 public PermissionName getFullName() 44 { 45 return fullName; 46 } 47 48 public boolean implies(Permission p) 49 { 50 String pactions = p.getActions(); 51 boolean implied = true; 52 for(int n = 0; n < actions.length(); n ++) 53 { 54 char a = actions.charAt(n); 55 char pa = pactions.charAt(n); 56 if( (a != '-' && pa != '-' && pa != a) ) 57 { 58 implied = false; 59 break; 60 } 61 else if( a == '-' && pa != '-' ) 62 { 63 implied = false; 64 break; 65 } 66 } 67 return implied; 68 } 69 70 public PermissionCollection newPermissionCollection() 71 { 72 return new NamespacePermissionCollection(); 73 } 74 } 75 | Popular Tags |