KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > SecurityMap


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class SecurityMap matches the DTD element security-map
26  *
27  */

28
29 package com.sun.enterprise.config.serverbeans;
30
31 import org.w3c.dom.*;
32 import org.netbeans.modules.schema2beans.*;
33 import java.beans.*;
34 import java.util.*;
35 import java.io.Serializable JavaDoc;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.config.StaleWriteConfigException;
39 import com.sun.enterprise.util.i18n.StringManager;
40
41 // BEGIN_NOI18N
42

43 public class SecurityMap extends ConfigBean implements Serializable JavaDoc
44 {
45
46     static Vector comparators = new Vector();
47     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
48
49     static public final String JavaDoc PRINCIPAL = "Principal";
50     static public final String JavaDoc USER_GROUP = "UserGroup";
51     static public final String JavaDoc BACKEND_PRINCIPAL = "BackendPrincipal";
52
53     public SecurityMap() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public SecurityMap(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("principal", PRINCIPAL, Common.SEQUENCE_OR |
63             Common.TYPE_1_N | Common.TYPE_STRING | Common.TYPE_KEY,
64             String JavaDoc.class);
65         this.createProperty("user-group", USER_GROUP, Common.SEQUENCE_OR |
66             Common.TYPE_1_N | Common.TYPE_STRING | Common.TYPE_KEY,
67             String JavaDoc.class);
68         this.createProperty("backend-principal", BACKEND_PRINCIPAL,
69             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
70             BackendPrincipal.class);
71         this.createAttribute(BACKEND_PRINCIPAL, "user-name", "UserName",
72                         AttrProp.CDATA | AttrProp.REQUIRED,
73                         null, null);
74         this.createAttribute(BACKEND_PRINCIPAL, "password", "Password",
75                         AttrProp.CDATA | AttrProp.IMPLIED,
76                         null, null);
77         this.initialize(options);
78     }
79
80     // Setting the default values of the properties
81
void initialize(int options) {
82
83     }
84
85     // This attribute is an array containing at least one element
86
public void setPrincipal(String JavaDoc[] value) {
87         this.setValue(PRINCIPAL, value);
88     }
89
90     // Getter Method
91
public String JavaDoc[] getPrincipal() {
92         return (String JavaDoc[])this.getValues(PRINCIPAL);
93     }
94
95     // Return the number of properties
96
public int sizePrincipal() {
97         return this.size(PRINCIPAL);
98     }
99
100     // Add a new element returning its index in the list
101
public int addPrincipal(String JavaDoc value)
102             throws ConfigException{
103         return addPrincipal(value, true);
104     }
105
106     // Add a new element returning its index in the list with a boolean flag
107
public int addPrincipal(String JavaDoc value, boolean overwrite)
108             throws ConfigException{
109         return this.addValue(PRINCIPAL, value, overwrite);
110     }
111
112     //
113
// Remove an element using its reference
114
// Returns the index the element had in the list
115
//
116
public int removePrincipal(String JavaDoc value){
117         return this.removeValue(PRINCIPAL, value);
118     }
119
120     //
121
// Remove an element using its reference
122
// Returns the index the element had in the list
123
// with boolean overwrite
124
//
125
public int removePrincipal(String JavaDoc value, boolean overwrite)
126             throws StaleWriteConfigException{
127         return this.removeValue(PRINCIPAL, value, overwrite);
128     }
129
130     // This attribute is an array containing at least one element
131
public void setUserGroup(String JavaDoc[] value) {
132         this.setValue(USER_GROUP, value);
133     }
134
135     // Getter Method
136
public String JavaDoc[] getUserGroup() {
137         return (String JavaDoc[])this.getValues(USER_GROUP);
138     }
139
140     // Return the number of properties
141
public int sizeUserGroup() {
142         return this.size(USER_GROUP);
143     }
144
145     // Add a new element returning its index in the list
146
public int addUserGroup(String JavaDoc value)
147             throws ConfigException{
148         return addUserGroup(value, true);
149     }
150
151     // Add a new element returning its index in the list with a boolean flag
152
public int addUserGroup(String JavaDoc value, boolean overwrite)
153             throws ConfigException{
154         return this.addValue(USER_GROUP, value, overwrite);
155     }
156
157     //
158
// Remove an element using its reference
159
// Returns the index the element had in the list
160
//
161
public int removeUserGroup(String JavaDoc value){
162         return this.removeValue(USER_GROUP, value);
163     }
164
165     //
166
// Remove an element using its reference
167
// Returns the index the element had in the list
168
// with boolean overwrite
169
//
170
public int removeUserGroup(String JavaDoc value, boolean overwrite)
171             throws StaleWriteConfigException{
172         return this.removeValue(USER_GROUP, value, overwrite);
173     }
174
175     // This attribute is mandatory
176
public void setBackendPrincipal(BackendPrincipal value) {
177         this.setValue(BACKEND_PRINCIPAL, value);
178     }
179
180     // Get Method
181
public BackendPrincipal getBackendPrincipal() {
182         return (BackendPrincipal)this.getValue(BACKEND_PRINCIPAL);
183     }
184
185     /**
186     * Getter for Name of the Element security-map
187     * @return the Name of the Element security-map
188     */

189     public String JavaDoc getName() {
190         return getAttributeValue(ServerTags.NAME);
191     }
192     /**
193     * Modify the Name of the Element security-map
194     * @param v the new value
195     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
196     */

197     public void setName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
198         setAttributeValue(ServerTags.NAME, v, overwrite);
199     }
200     /**
201     * Modify the Name of the Element security-map
202     * @param v the new value
203     */

204     public void setName(String JavaDoc v) {
205         setAttributeValue(ServerTags.NAME, v);
206     }
207     /**
208      * Create a new bean using it's default constructor.
209      * This does not add it to any bean graph.
210      */

211     public BackendPrincipal newBackendPrincipal() {
212         return new BackendPrincipal();
213     }
214
215     /**
216     * get the xpath representation for this element
217     * returns something like abc[@name='value'] or abc
218     * depending on the type of the bean
219     */

220     protected String JavaDoc getRelativeXPath() {
221         String JavaDoc ret = null;
222         ret = "security-map" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ;
223         return (null != ret ? ret.trim() : null);
224     }
225
226     /*
227     * generic method to get default value from dtd
228     */

229     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
230         if(attr == null) return null;
231         attr = attr.trim();
232     return null;
233     }
234     //
235
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
236         comparators.add(c);
237     }
238
239     //
240
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
241         comparators.remove(c);
242     }
243     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
244     }
245
246     // Dump the content of this bean returning it as a String
247
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
248         String JavaDoc s;
249         Object JavaDoc o;
250         org.netbeans.modules.schema2beans.BaseBean n;
251         str.append(indent);
252         str.append("Principal["+this.sizePrincipal()+"]"); // NOI18N
253
for(int i=0; i<this.sizePrincipal(); i++)
254         {
255             str.append(indent+"\t");
256             str.append("#"+i+":");
257             str.append(indent+"\t"); // NOI18N
258
str.append("<"); // NOI18N
259
o = this.getValue(PRINCIPAL, i);
260             str.append((o==null?"null":o.toString().trim())); // NOI18N
261
str.append(">\n"); // NOI18N
262
this.dumpAttributes(PRINCIPAL, i, str, indent);
263         }
264
265         str.append(indent);
266         str.append("UserGroup["+this.sizeUserGroup()+"]"); // NOI18N
267
for(int i=0; i<this.sizeUserGroup(); i++)
268         {
269             str.append(indent+"\t");
270             str.append("#"+i+":");
271             str.append(indent+"\t"); // NOI18N
272
str.append("<"); // NOI18N
273
o = this.getValue(USER_GROUP, i);
274             str.append((o==null?"null":o.toString().trim())); // NOI18N
275
str.append(">\n"); // NOI18N
276
this.dumpAttributes(USER_GROUP, i, str, indent);
277         }
278
279         str.append(indent);
280         str.append("BackendPrincipal"); // NOI18N
281
n = (org.netbeans.modules.schema2beans.BaseBean) this.getBackendPrincipal();
282         if (n != null)
283             n.dump(str, indent + "\t"); // NOI18N
284
else
285             str.append(indent+"\tnull"); // NOI18N
286
this.dumpAttributes(BACKEND_PRINCIPAL, 0, str, indent);
287
288     }
289     public String JavaDoc dumpBeanNode(){
290         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
291         str.append("SecurityMap\n"); // NOI18N
292
this.dump(str, "\n "); // NOI18N
293
return str.toString();
294     }}
295
296 // END_NOI18N
297

298
Popular Tags