KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > security > PermissionImpl


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.security;
14
15 import info.magnolia.cms.util.UrlPattern;
16
17 import java.io.Serializable JavaDoc;
18 import java.util.Hashtable JavaDoc;
19 import java.util.Map JavaDoc;
20
21
22 /**
23  * @author Sameer Charles
24  */

25 public class PermissionImpl implements Permission, Serializable JavaDoc {
26
27     /**
28      * Stable serialVersionUID.
29      */

30     private static final long serialVersionUID = 222L;
31
32     private static Map JavaDoc nameStrings = new Hashtable JavaDoc();
33
34     static {
35         nameStrings.put(new Long JavaDoc(Permission.ADD), Permission.PERMISSION_NAME_ADD);
36         nameStrings.put(new Long JavaDoc(Permission.SET), Permission.PERMISSION_NAME_SET);
37         nameStrings.put(new Long JavaDoc(Permission.REMOVE), Permission.PERMISSION_NAME_REMOVE);
38         nameStrings.put(new Long JavaDoc(Permission.READ), Permission.PERMISSION_NAME_READ);
39         nameStrings.put(new Long JavaDoc(Permission.EXECUTE), Permission.PERMISSION_NAME_EXECUTE);
40         nameStrings.put(new Long JavaDoc(Permission.SYNDICATE), Permission.PERMISSION_NAME_SYNDICATE);
41         nameStrings.put(new Long JavaDoc(Permission.ALL), Permission.PERMISSION_NAME_ALL);
42         nameStrings.put(new Long JavaDoc(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 JavaDoc path) {
66         return this.pattern.match(path);
67     }
68
69     public static String JavaDoc getPermissionAsName(long permission) {
70         return (String JavaDoc) nameStrings.get(new Long JavaDoc(permission));
71     }
72 }
73
Popular Tags