1 13 package info.magnolia.cms.security; 14 15 import info.magnolia.cms.util.UrlPattern; 16 17 import java.io.Serializable ; 18 import java.util.Hashtable ; 19 import java.util.Map ; 20 21 22 25 public class PermissionImpl implements Permission, Serializable { 26 27 30 private static final long serialVersionUID = 222L; 31 32 private static Map nameStrings = new Hashtable (); 33 34 static { 35 nameStrings.put(new Long (Permission.ADD), Permission.PERMISSION_NAME_ADD); 36 nameStrings.put(new Long (Permission.SET), Permission.PERMISSION_NAME_SET); 37 nameStrings.put(new Long (Permission.REMOVE), Permission.PERMISSION_NAME_REMOVE); 38 nameStrings.put(new Long (Permission.READ), Permission.PERMISSION_NAME_READ); 39 nameStrings.put(new Long (Permission.EXECUTE), Permission.PERMISSION_NAME_EXECUTE); 40 nameStrings.put(new Long (Permission.SYNDICATE), Permission.PERMISSION_NAME_SYNDICATE); 41 nameStrings.put(new Long (Permission.ALL), Permission.PERMISSION_NAME_ALL); 42 nameStrings.put(new Long (Permission.WRITE), Permission.PERMISSION_NAME_WRITE); 43 } 44 45 private UrlPattern pattern; 46 47 private long permissions; 48 49 public void setPattern(UrlPattern value) { 50 this.pattern = value; 51 } 52 53 public UrlPattern getPattern() { 54 return this.pattern; 55 } 56 57 public void setPermissions(long value) { 58 this.permissions = value; 59 } 60 61 public long getPermissions() { 62 return this.permissions; 63 } 64 65 public boolean match(String path) { 66 return this.pattern.match(path); 67 } 68 69 public static String getPermissionAsName(long permission) { 70 return (String ) nameStrings.get(new Long (permission)); 71 } 72 } 73 | Popular Tags |