KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > realm > principals > Role


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 1any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: Role.java,v 1.2 2004/05/25 15:13:29 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.security.realm.principals;
28
29 import java.io.Serializable JavaDoc;
30
31 /**
32  * This class define the Role class which define a role with its name and
33  * description.
34  * @author Florent Benoit
35  */

36 public class Role implements Serializable JavaDoc, RoleMBean {
37
38     /**
39      * Name of the role
40      */

41     private String JavaDoc name = null;
42
43     /**
44      * Description of the role
45      */

46     private String JavaDoc description = null;
47
48     /**
49      * Constructor
50      */

51     public Role() {
52
53     }
54
55     /**
56      * Constructor with a specific role name
57      * @param name the role name to use
58      */

59     public Role(String JavaDoc name) {
60         setName(name);
61     }
62
63     /**
64      * Set the name of this role
65      * @param name Name of the role
66      */

67     public void setName(String JavaDoc name) {
68         this.name = name;
69     }
70
71     /**
72      * Get the name of this role
73      * @return the name of this role
74      */

75     public String JavaDoc getName() {
76         return name;
77     }
78
79     /**
80      * Set the description of this role
81      * @param description description of the role
82      */

83     public void setDescription(String JavaDoc description) {
84         this.description = description;
85     }
86
87     /**
88      * Get the description of this role
89      * @return the description of this role
90      */

91     public String JavaDoc getDescription() {
92         return description;
93     }
94
95     /**
96      * String representation of the role
97      * @return the xml representation of the role
98      */

99     public String JavaDoc toXML() {
100         StringBuffer JavaDoc xml = new StringBuffer JavaDoc("<role name=\"");
101         xml.append(name);
102         xml.append("\" description=\"");
103         if (description != null) {
104             xml.append(description);
105         }
106         xml.append("\" />");
107         return xml.toString();
108     }
109
110     /**
111      * Use the XML representation of this object
112      * @return the XML representation of this object
113      */

114     public String JavaDoc toString() {
115         return this.toXML();
116     }
117
118 }
Popular Tags