001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: *
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or 1any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: * Initial developer: Florent Benoit
023: * --------------------------------------------------------------------------
024: * $Id: JonasRunAsMapping.java 5030 2004-07-01 09:52:36Z benoitf $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_ejb.deployment.xml;
027:
028: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
029: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
030:
031: /**
032: * This class defines the implementation of the element jonas-run-as-mapping It
033: * defines mapping between principal and list of roles
034: * @author Florent Benoit
035: */
036:
037: public class JonasRunAsMapping extends AbsElement {
038:
039: /**
040: * principal name
041: */
042: private String principalName = null;
043:
044: /**
045: * role names
046: */
047: private JLinkedList roleNamesList = null;
048:
049: /**
050: * Constructor
051: */
052: public JonasRunAsMapping() {
053: super ();
054: roleNamesList = new JLinkedList("role-name");
055: }
056:
057: /**
058: * Gets the role-name
059: * @return the role-name
060: */
061: public JLinkedList getRoleNamesList() {
062: return roleNamesList;
063: }
064:
065: /**
066: * Add a new role-name element to this object
067: * @param roleName the name of the role
068: */
069: public void addRoleName(String roleName) {
070: roleNamesList.add(roleName);
071: }
072:
073: /**
074: * @return the principal Name.
075: */
076: public String getPrincipalName() {
077: return principalName;
078: }
079:
080: /**
081: * Sets the principal name
082: * @param principalName name of the principal to set.
083: */
084: public void setPrincipalName(String principalName) {
085: this .principalName = principalName;
086: }
087:
088: /**
089: * Represents this element by it's XML description.
090: * @param indent use this indent for prexifing XML representation.
091: * @return the XML description of this object.
092: */
093: public String toXML(int indent) {
094: StringBuffer sb = new StringBuffer();
095: sb.append(indent(indent));
096: sb.append("<jonas-run-as-mapping>\n");
097:
098: indent += 2;
099:
100: // principal-name
101: sb.append(xmlElement(principalName, "principal-name", indent));
102:
103: // role-name
104: sb.append(roleNamesList.toXML(indent));
105:
106: indent -= 2;
107: sb.append(indent(indent));
108: sb.append("</jonas-run-as-mapping>\n");
109:
110: return sb.toString();
111: }
112: }
|