001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 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 any 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: SecurityRoleMapping.java 5124 2004-07-13 15:20:41Z benoitf $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_ear.deployment.xml;
026:
027: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
028: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
029:
030: /**
031: * This class defines the implementation of the element security-role-mapping.
032: * It allow to define mapping between roles and principal which use these roles.
033: * @author Florent Benoit
034: */
035:
036: public class SecurityRoleMapping extends AbsElement {
037:
038: /**
039: * role name
040: */
041: private String roleName = null;
042:
043: /**
044: * principal names
045: */
046: private JLinkedList principalNamesList = null;
047:
048: /**
049: * Constructor
050: */
051: public SecurityRoleMapping() {
052: super ();
053: principalNamesList = new JLinkedList("principal-name");
054: }
055:
056: /**
057: * Gets the principal-name list
058: * @return the principal-name list
059: */
060: public JLinkedList getPrincipalNamesList() {
061: return principalNamesList;
062: }
063:
064: /**
065: * Set the role-name element of this object
066: * @param roleName the name of the role
067: */
068: public void setRoleName(String roleName) {
069: this .roleName = roleName;
070: }
071:
072: /**
073: * @return the role Name.
074: */
075: public String getRoleName() {
076: return roleName;
077: }
078:
079: /**
080: * Add the given principal to the list of principals
081: * @param principalName name of the principal to add.
082: */
083: public void addPrincipalName(String principalName) {
084: principalNamesList.add(principalName);
085: }
086:
087: /**
088: * Represents this element by it's XML description.
089: * @param indent use this indent for prexifing XML representation.
090: * @return the XML description of this object.
091: */
092: public String toXML(int indent) {
093: StringBuffer sb = new StringBuffer();
094: sb.append(indent(indent));
095: sb.append("<security-role-mapping>\n");
096:
097: indent += 2;
098:
099: // role-name
100: sb.append(xmlElement(roleName, "role-name", indent));
101:
102: // principal-name
103: sb.append(principalNamesList.toXML(indent));
104:
105: indent -= 2;
106: sb.append(indent(indent));
107: sb.append("</security-role-mapping>\n");
108:
109: return sb.toString();
110: }
111: }
|