1 22 package org.jboss.test.security.test; 23 24 import java.security.BasicPermission ; 25 import java.security.Permission ; 26 import java.security.PermissionCollection ; 27 import javax.naming.Name ; 28 29 34 public class NamespacePermission extends BasicPermission 35 { 36 private PermissionName fullName; 37 private String actions; 38 39 40 public NamespacePermission(String name, String actions) 41 { 42 super(name, actions); 43 this.actions = actions; 44 fullName = new PermissionName(name); 45 } 46 public NamespacePermission(Name name, String actions) 47 { 48 super(name.toString(), actions); 49 this.actions = actions; 50 fullName = new PermissionName(name); 51 } 52 53 public String getActions() 54 { 55 return actions; 56 } 57 58 public PermissionName getFullName() 59 { 60 return fullName; 61 } 62 63 public boolean implies(Permission p) 64 { 65 String pactions = p.getActions(); 66 boolean implied = true; 67 for(int n = 0; n < actions.length(); n ++) 68 { 69 char a = actions.charAt(n); 70 char pa = pactions.charAt(n); 71 if( (a != '-' && pa != '-' && pa != a) ) 72 { 73 implied = false; 74 break; 75 } 76 else if( a == '-' && pa != '-' ) 77 { 78 implied = false; 79 break; 80 } 81 } 82 return implied; 83 } 84 85 public PermissionCollection newPermissionCollection() 86 { 87 return new NamespacePermissionCollection(); 88 } 89 } 90 | Popular Tags |