Source Code Cross Referenced for PersistentRoleSecurityBinding.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » impl » model » instance » persistent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » jboss portal 2.6.4 » org.jboss.portal.core.impl.model.instance.persistent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.impl.model.instance.persistent;
023:
024:        import org.jboss.portal.core.model.instance.Instance;
025:
026:        import java.io.Serializable;
027:        import java.util.Collections;
028:        import java.util.HashSet;
029:        import java.util.Iterator;
030:        import java.util.Set;
031:        import java.util.StringTokenizer;
032:
033:        /**
034:         * Security Constraint for an instance
035:         *
036:         * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
037:         * @version $Revision: 8786 $
038:         */
039:        final class PersistentRoleSecurityBinding implements  Serializable {
040:
041:            /** The serialVersionUID */
042:            private static final long serialVersionUID = -2832148715381794267L;
043:
044:            /** The primary key. */
045:            private Long key;
046:
047:            /** The role of this contraint. */
048:            private String role;
049:
050:            /** The set of actions of this constraint. */
051:            private Set actions;
052:
053:            /** The cached toString value. */
054:            private transient String toString;
055:
056:            /** The cached hash code. */
057:            private transient int hashCode;
058:
059:            /** The cached actions as a string. */
060:            private transient String actionsAsString;
061:
062:            private Instance instance;
063:
064:            public PersistentRoleSecurityBinding() {
065:                super ();
066:            }
067:
068:            /**
069:             * Create a new constraint with the provided actions for the specified role.
070:             *
071:             * @param actions a comma separated list of allowed actions
072:             * @param role    the role name
073:             */
074:            public PersistentRoleSecurityBinding(String actions, String role) {
075:                if (role == null) {
076:                    throw new IllegalArgumentException("Role cannot be null");
077:                }
078:                if (actions == null) {
079:                    throw new IllegalArgumentException("Actions cannot be null");
080:                }
081:
082:                //
083:                StringTokenizer tokens = new StringTokenizer(actions, ",");
084:                Set set = new HashSet();
085:                while (tokens.hasMoreTokens()) {
086:                    set.add(tokens.nextToken().trim());
087:                }
088:
089:                //
090:                this .role = role;
091:                this .actions = Collections.unmodifiableSet(set);
092:            }
093:
094:            /**
095:             * Create a new constraint with the provided actions and the specified role.
096:             *
097:             * @param actions the set of actions
098:             * @param role    the role name
099:             */
100:            public PersistentRoleSecurityBinding(Set actions, String role) {
101:                if (role == null) {
102:                    throw new IllegalArgumentException("Role cannot be null");
103:                }
104:                if (actions == null) {
105:                    throw new IllegalArgumentException("Actions cannot be null");
106:                }
107:
108:                //
109:                this .role = role;
110:                this .actions = Collections
111:                        .unmodifiableSet(new HashSet(actions));
112:            }
113:
114:            /** Copy constructor. */
115:            public PersistentRoleSecurityBinding(
116:                    PersistentRoleSecurityBinding other) {
117:                if (other == null) {
118:                    throw new IllegalArgumentException(
119:                            "The constraint to clone cannot be null");
120:                }
121:
122:                //
123:                this .role = other.role;
124:                this .actions = other.actions;
125:            }
126:
127:            /**
128:             * Return a <code>java.util.Set<String></code> of allowed actions.
129:             *
130:             * @return the action set
131:             */
132:            public Set getActions() {
133:                return actions;
134:            }
135:
136:            /**
137:             * Return the role of this constraint
138:             *
139:             * @return the role
140:             */
141:            public String getRole() {
142:                return role;
143:            }
144:
145:            /**
146:             * Return a comma separated list of actions.
147:             *
148:             * @return the action string representation
149:             */
150:            public String getActionsAsString() {
151:                if (actionsAsString == null) {
152:                    StringBuffer tmp = new StringBuffer();
153:                    for (Iterator i = actions.iterator(); i.hasNext();) {
154:                        String action = (String) i.next();
155:                        if (i.hasNext()) {
156:                            tmp.append(", ");
157:                        }
158:                        tmp.append(action);
159:                    }
160:                    actionsAsString = tmp.toString();
161:                }
162:                return actionsAsString;
163:            }
164:
165:            /** @see Object#toString */
166:            public String toString() {
167:                if (toString == null) {
168:                    StringBuffer tmp = new StringBuffer(
169:                            "SecurityConstraint: actions [");
170:                    for (Iterator i = actions.iterator(); i.hasNext();) {
171:                        String action = (String) i.next();
172:                        if (i.hasNext()) {
173:                            tmp.append(", ");
174:                        }
175:                        tmp.append(action);
176:                    }
177:                    tmp.append("] role [").append(role).append("]");
178:                    toString = tmp.toString();
179:                }
180:                return toString;
181:            }
182:
183:            public boolean equals(Object o) {
184:                if (this  == o) {
185:                    return true;
186:                }
187:                if (o instanceof  PersistentRoleSecurityBinding) {
188:                    PersistentRoleSecurityBinding that = (PersistentRoleSecurityBinding) o;
189:                    return actions.equals(that.actions)
190:                            && role.equals(that.role);
191:                }
192:                return false;
193:            }
194:
195:            public int hashCode() {
196:                if (hashCode == 0) {
197:                    int hashCode;
198:                    hashCode = actions.hashCode();
199:                    hashCode = 29 * hashCode + role.hashCode();
200:                    this .hashCode = hashCode;
201:                }
202:                return hashCode;
203:            }
204:
205:            protected void setKey(Long k) {
206:                key = k;
207:            }
208:
209:            protected Long getKey() {
210:                return key;
211:            }
212:
213:            public void setActions(Set actions) {
214:                this .actions = actions;
215:            }
216:
217:            public void setRole(String role) {
218:                this .role = role;
219:            }
220:
221:            public Instance getInstance() {
222:                return instance;
223:            }
224:
225:            public void setInstance(Instance instance) {
226:                this.instance = instance;
227:            }
228:        }
w__w__w_._jav_a__2___s.__c___o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.