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: Role.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:
029: /**
030: * This class define the Role class which define a role with its name and
031: * description.
032: * @author Florent Benoit
033: */
034: public class Role implements Serializable, RoleMBean {
035:
036: /**
037: * Name of the role
038: */
039: private String name = null;
040:
041: /**
042: * Description of the role
043: */
044: private String description = null;
045:
046: /**
047: * Constructor
048: */
049: public Role() {
050:
051: }
052:
053: /**
054: * Constructor with a specific role name
055: * @param name the role name to use
056: */
057: public Role(String name) {
058: setName(name);
059: }
060:
061: /**
062: * Set the name of this role
063: * @param name Name of the role
064: */
065: public void setName(String name) {
066: this .name = name;
067: }
068:
069: /**
070: * Get the name of this role
071: * @return the name of this role
072: */
073: public String getName() {
074: return name;
075: }
076:
077: /**
078: * Set the description of this role
079: * @param description description of the role
080: */
081: public void setDescription(String description) {
082: this .description = description;
083: }
084:
085: /**
086: * Get the description of this role
087: * @return the description of this role
088: */
089: public String getDescription() {
090: return description;
091: }
092:
093: /**
094: * String representation of the role
095: * @return the xml representation of the role
096: */
097: public String toXML() {
098: StringBuffer xml = new StringBuffer("<role name=\"");
099: xml.append(name);
100: xml.append("\" description=\"");
101: if (description != null) {
102: xml.append(description);
103: }
104: xml.append("\" />");
105: return xml.toString();
106: }
107:
108: /**
109: * Use the XML representation of this object
110: * @return the XML representation of this object
111: */
112: public String toString() {
113: return this.toXML();
114: }
115:
116: }
|