KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > jaas > principal > ACLImpl


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.jaas.principal;
14
15 import info.magnolia.cms.security.auth.ACL;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.apache.commons.lang.builder.ToStringBuilder;
22 import org.apache.commons.lang.builder.ToStringStyle;
23
24
25 /**
26  * This class represents access control list as a principal
27  * @author Sameer Charles $Id: ACLImpl.java 6341 2006-09-12 09:18:27Z philipp $
28  */

29 public class ACLImpl implements ACL {
30
31     /**
32      * Stable serialVersionUID.
33      */

34     private static final long serialVersionUID = 222L;
35
36     private static final String JavaDoc NAME = "acl";
37
38     /**
39      * properties
40      */

41     private String JavaDoc name;
42
43     private List JavaDoc list;
44
45     private String JavaDoc repository;
46
47     private String JavaDoc workspace;
48
49     /**
50      * Constructor
51      */

52     public ACLImpl() {
53         this.list = new ArrayList JavaDoc();
54     }
55
56     /**
57      * Get name given to this principal
58      * @return name
59      */

60     public String JavaDoc getName() {
61         if (StringUtils.isEmpty(this.name)) {
62             return NAME;
63         }
64         return this.name;
65     }
66
67     /**
68      * Set this principal name
69      */

70     public void setName(String JavaDoc name) {
71         this.name = name;
72     }
73
74     /**
75      * Get repository ID for which this ACL has been constructed
76      * @return repository ID
77      */

78     public String JavaDoc getRepository() {
79         return this.repository;
80     }
81
82     /**
83      * Set repository ID for which this ACL will be constructed
84      * @param repository
85      */

86     public void setRepository(String JavaDoc repository) {
87         this.repository = repository;
88     }
89
90     /**
91      * Get workspace ID for which this ACL has been contructed
92      * @return workspace ID
93      */

94     public String JavaDoc getWorkspace() {
95         return this.workspace;
96     }
97
98     /**
99      * Set workspace ID for which this ACL will be constructed
100      * @param workspace
101      */

102     public void setWorkspace(String JavaDoc workspace) {
103         this.workspace = workspace;
104     }
105
106     /**
107      * add permission in to an existing list
108      * @param permission
109      */

110     public void addPermission(Object JavaDoc permission) {
111         this.list.add(permission);
112     }
113
114     /**
115      * Initialize access control list with provided permissions it will overwrite any existing permissions set before.
116      * @param list
117      */

118     public void setList(List JavaDoc list) {
119         this.list.clear();
120         this.list.addAll(list);
121     }
122
123     /**
124      * Returns list of permissions for this principal
125      */

126     public List JavaDoc getList() {
127         return this.list;
128     }
129
130     /**
131      * @see java.lang.Object#toString()
132      */

133     public String JavaDoc toString() {
134         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("name", this.name).append(
135             "workspace",
136             this.workspace).append("repository", this.repository).append("list", this.list).toString();
137     }
138
139 }
140
Popular Tags