Source Code Cross Referenced for Group.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » security » realm » principals » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.security.realm.principals 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Florent BENOIT
022:         * --------------------------------------------------------------------------
023:         * $Id: Group.java 4804 2004-05-25 15:13:29Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.security.realm.principals;
026:
027:        import java.io.Serializable;
028:        import java.util.Enumeration;
029:        import java.util.StringTokenizer;
030:        import java.util.Vector;
031:
032:        import org.objectweb.jonas.security.realm.lib.XML;
033:
034:        /**
035:         * This class define the Group class which represent a group with its associated
036:         * roles
037:         * @author Florent Benoit
038:         */
039:
040:        public class Group implements  Serializable, GroupMBean {
041:
042:            /**
043:             * Separator of the roles
044:             */
045:            protected static final String SEPARATOR = ",";
046:
047:            /**
048:             * Name of the user
049:             */
050:            private String name = null;
051:
052:            /**
053:             * Roles
054:             */
055:            private Vector roles = new Vector();
056:
057:            /**
058:             * Description of the role
059:             */
060:            private String description = null;
061:
062:            /**
063:             * Default Constructor
064:             */
065:            public Group() {
066:
067:            }
068:
069:            /**
070:             * Constructor with a given name
071:             * @param name the name of this group
072:             */
073:            public Group(String name) {
074:                setName(name);
075:            }
076:
077:            /**
078:             * Set the name of this user
079:             * @param name Name of the user
080:             */
081:            public void setName(String name) {
082:                this .name = name;
083:            }
084:
085:            /**
086:             * Get the name of this user
087:             * @return the name of this user
088:             */
089:            public String getName() {
090:                return name;
091:            }
092:
093:            /**
094:             * Set the description of this group
095:             * @param description description of the group
096:             */
097:            public void setDescription(String description) {
098:                this .description = description;
099:            }
100:
101:            /**
102:             * Get the description of this group
103:             * @return the description of this group
104:             */
105:            public String getDescription() {
106:                return description;
107:            }
108:
109:            /**
110:             * Set the roles of the group
111:             * @param roles the list of the roles of the group
112:             */
113:            public void setRoles(String roles) {
114:                StringTokenizer st = new StringTokenizer(roles, SEPARATOR);
115:                String role = null;
116:                while (st.hasMoreTokens()) {
117:                    role = st.nextToken().trim();
118:                    addRole(role);
119:                }
120:            }
121:
122:            /**
123:             * Add a role to this group
124:             * @param role the given role
125:             */
126:            public void addRole(String role) {
127:                if (!roles.contains(role)) {
128:                    this .roles.addElement(role);
129:                }
130:            }
131:
132:            /**
133:             * Remove a role from this group
134:             * @param role the given role
135:             */
136:            public void removeRole(String role) {
137:                if (roles.contains(role)) {
138:                    this .roles.removeElement(role);
139:                }
140:            }
141:
142:            /**
143:             * Get the roles
144:             * @return the array of the roles
145:             */
146:            public String getRoles() {
147:                String rolesList = "";
148:                Enumeration r = roles.elements();
149:                int nb = 0;
150:                String role = null;
151:
152:                while (r.hasMoreElements()) {
153:                    if (nb > 0) {
154:                        rolesList += ", ";
155:                    }
156:                    role = (String) r.nextElement();
157:                    rolesList += role;
158:                }
159:                return rolesList;
160:            }
161:
162:            /**
163:             * Get the roles
164:             * @return the array of the roles
165:             */
166:            public String[] getArrayRoles() {
167:                return ((String[]) roles.toArray(new String[roles.size()]));
168:            }
169:
170:            /**
171:             * String representation of the group
172:             * @return the xml representation of the group
173:             */
174:            public String toXML() {
175:                StringBuffer xml = new StringBuffer("<group name=\"");
176:                xml.append(name);
177:                xml.append("\" description=\"");
178:                if (description != null) {
179:                    xml.append(description);
180:                }
181:                xml.append("\"");
182:                XML.appendVectorToBuffer("roles=", xml, roles);
183:                xml.append(" />");
184:                return xml.toString();
185:            }
186:
187:            /**
188:             * Use the XML representation of this object
189:             * @return the XML representation of this object
190:             */
191:            public String toString() {
192:                return this.toXML();
193:            }
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.