KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ear > deployment > xml > SecurityRoleMapping


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 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 any 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: SecurityRoleMapping.java,v 1.1 2004/07/13 15:20:40 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26 package org.objectweb.jonas_ear.deployment.xml;
27
28 import org.objectweb.jonas_lib.deployment.xml.AbsElement;
29 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
30
31 /**
32  * This class defines the implementation of the element security-role-mapping.
33  * It allow to define mapping between roles and principal which use these roles.
34  * @author Florent Benoit
35  */

36
37 public class SecurityRoleMapping extends AbsElement {
38
39     /**
40      * role name
41      */

42     private String JavaDoc roleName = null;
43
44     /**
45      * principal names
46      */

47     private JLinkedList principalNamesList = null;
48
49     /**
50      * Constructor
51      */

52     public SecurityRoleMapping() {
53         super();
54         principalNamesList = new JLinkedList("principal-name");
55     }
56
57     /**
58      * Gets the principal-name list
59      * @return the principal-name list
60      */

61     public JLinkedList getPrincipalNamesList() {
62         return principalNamesList;
63     }
64
65     /**
66      * Set the role-name element of this object
67      * @param roleName the name of the role
68      */

69     public void setRoleName(String JavaDoc roleName) {
70         this.roleName = roleName;
71     }
72
73     /**
74      * @return the role Name.
75      */

76     public String JavaDoc getRoleName() {
77         return roleName;
78     }
79
80     /**
81      * Add the given principal to the list of principals
82      * @param principalName name of the principal to add.
83      */

84     public void addPrincipalName(String JavaDoc principalName) {
85         principalNamesList.add(principalName);
86     }
87
88     /**
89      * Represents this element by it's XML description.
90      * @param indent use this indent for prexifing XML representation.
91      * @return the XML description of this object.
92      */

93     public String JavaDoc toXML(int indent) {
94         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
95         sb.append(indent(indent));
96         sb.append("<security-role-mapping>\n");
97
98         indent += 2;
99
100         // role-name
101
sb.append(xmlElement(roleName, "role-name", indent));
102
103         // principal-name
104
sb.append(principalNamesList.toXML(indent));
105
106         indent -= 2;
107         sb.append(indent(indent));
108         sb.append("</security-role-mapping>\n");
109
110         return sb.toString();
111     }
112 }
Popular Tags