KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > realm > JDBCRealmForm


1 /*
2  * Copyright 2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.webapp.admin.realm;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import org.apache.struts.action.ActionError;
21 import org.apache.struts.action.ActionErrors;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionMapping;
24 import java.net.InetAddress JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.apache.webapp.admin.ApplicationServlet;
28 import org.apache.webapp.admin.LabelValueBean;
29
30 /**
31  * Form bean for the jdbc realm page.
32  *
33  * @author Manveen Kaur
34  * @version $Revision: 1.4 $ $Date: 2004/06/28 02:14:51 $
35  */

36
37 public final class JDBCRealmForm extends RealmForm {
38     
39     // ----------------------------------------------------- Instance Variables
40

41     /**
42      * The text for the realm name, used to retrieve
43      * the corresponding realm mBean.
44      */

45     private String JavaDoc realmName = null;
46       
47     /**
48      * The text for the digest.
49      */

50     private String JavaDoc digest = null;
51     
52     /**
53      * The text for the roleNameCol.
54      */

55     private String JavaDoc roleNameCol = null;
56
57     /**
58      * The text for the userNameCol.
59      */

60     private String JavaDoc userNameCol = null;
61
62     /**
63      * The text for the passwordCol.
64      */

65     private String JavaDoc passwordCol = null;
66     
67     /**
68      * The text for the driver.
69      */

70     private String JavaDoc driver = null;
71         
72     /**
73      * The text for the role table.
74      */

75     private String JavaDoc roleTable = null;
76     
77     /**
78      * The text for the user table.
79      */

80     private String JavaDoc userTable = null;
81         
82     /**
83      * The text for the connection user name.
84      */

85     private String JavaDoc connectionName = null;
86     
87     /**
88      * The text for the connection Password.
89      */

90     private String JavaDoc connectionPassword = null;
91     
92     /**
93      * The text for the connection URL.
94      */

95     private String JavaDoc connectionURL = null;
96     
97     // ------------------------------------------------------------- Properties
98

99     
100     /**
101      * Return the digest.
102      */

103     public String JavaDoc getDigest() {
104         
105         return this.digest;
106         
107     }
108     
109     /**
110      * Set the digest.
111      */

112     public void setDigest(String JavaDoc digest) {
113         
114         this.digest = digest;
115         
116     }
117     
118     /**
119      * Return the roleNameCol.
120      */

121     public String JavaDoc getRoleNameCol() {
122         
123         return this.roleNameCol;
124         
125     }
126     
127     /**
128      * Set the roleNameCol.
129      */

130     public void setRoleNameCol(String JavaDoc roleNameCol) {
131         
132         this.roleNameCol = roleNameCol;
133         
134     }
135     
136     /**
137      * Return the userNameCol.
138      */

139     public String JavaDoc getUserNameCol() {
140         
141         return this.userNameCol;
142         
143     }
144     
145     /**
146      * Set the userNameCol.
147      */

148     public void setUserNameCol(String JavaDoc userNameCol) {
149         
150         this.userNameCol = userNameCol;
151         
152     }
153     /**
154      * Return the driver.
155      */

156     public String JavaDoc getDriver() {
157         
158         return this.driver;
159         
160     }
161     
162     /**
163      * Set the driver.
164      */

165     public void setDriver(String JavaDoc driver) {
166         
167         this.driver = driver;
168         
169     }
170     
171     /**
172      * Return the role table.
173      */

174     public String JavaDoc getRoleTable() {
175         
176         return this.roleTable;
177         
178     }
179     
180     /**
181      * Set the roleTable.
182      */

183     public void setRoleTable(String JavaDoc roleTable) {
184         
185         this.roleTable = roleTable;
186         
187     }
188     
189     /**
190      * Return the user table.
191      */

192     public String JavaDoc getUserTable() {
193         
194         return this.userTable;
195         
196     }
197     
198     /**
199      * Set the user Table.
200      */

201     public void setUserTable(String JavaDoc userTable) {
202         
203         this.userTable = userTable;
204         
205     }
206     
207     /**
208      * Return the passwordCol.
209      */

210     public String JavaDoc getPasswordCol() {
211         
212         return this.passwordCol;
213         
214     }
215     
216     /**
217      * Set the passwordCol.
218      */

219     public void setPasswordCol(String JavaDoc passwordCol) {
220         
221         this.passwordCol = passwordCol;
222         
223     }
224     
225     
226     /**
227      * Return the connection name.
228      */

229     public String JavaDoc getConnectionName() {
230         
231         return this.connectionName;
232         
233     }
234     
235     /**
236      * Set the connectionName.
237      */

238     public void setConnectionName(String JavaDoc connectionName) {
239         
240         this.connectionName = connectionName;
241         
242     }
243     
244     
245     /**
246      * Return the connection password.
247      */

248     public String JavaDoc getConnectionPassword() {
249         
250         return this.connectionPassword;
251         
252     }
253     
254     /**
255      * Set the connection password.
256      */

257     public void setConnectionPassword(String JavaDoc connectionPassword) {
258         
259         this.connectionPassword = connectionPassword;
260         
261     }
262     
263     
264     /**
265      * Return the connection URL.
266      */

267     public String JavaDoc getConnectionURL() {
268         
269         return this.connectionURL;
270         
271     }
272     
273     /**
274      * Set the connectionURL.
275      */

276     public void setConnectionURL(String JavaDoc connectionURL) {
277         
278         this.connectionURL = connectionURL;
279         
280     }
281     
282     // --------------------------------------------------------- Public Methods
283

284     /**
285      * Reset all properties to their default values.
286      *
287      * @param mapping The mapping used to select this instance
288      * @param request The servlet request we are processing
289      */

290     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
291         
292         super.reset(mapping, request);
293         this.digest = null;
294         this.driver = null;
295         
296         this.roleNameCol = null;
297         this.userNameCol = null;
298         this.passwordCol = null;
299         this.userTable = null;
300         this.roleTable = null;
301         
302         this.connectionName = null;
303         this.connectionPassword = null;
304         this.connectionURL = null;
305         
306     }
307     
308     /**
309      * Render this object as a String.
310      */

311     public String JavaDoc toString() {
312
313         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("UserDatabaseRealmForm[adminAction=");
314         sb.append(getAdminAction());
315         sb.append(",digest=");
316         sb.append(digest);
317         sb.append("',driver='");
318         sb.append(driver);
319         sb.append("',roleNameCol=");
320         sb.append(roleNameCol);
321         sb.append("',userNameCol=");
322         sb.append(userNameCol);
323         sb.append(",passwordCol=");
324         sb.append(passwordCol);
325         sb.append("',userTable='");
326         sb.append(userTable);
327         sb.append("',roleTable=");
328         sb.append(roleTable);
329         sb.append(",connectionName=");
330         sb.append(connectionName);
331         sb.append("',connectionPassword=");
332         sb.append(connectionPassword);
333         sb.append(",connectionURL=");
334         sb.append(connectionURL);
335         sb.append("',objectName='");
336         sb.append(getObjectName());
337         sb.append("',realmType=");
338         sb.append(getRealmType());
339         sb.append("]");
340         return (sb.toString());
341
342     }
343     
344     /**
345      * Validate the properties that have been set from this HTTP request,
346      * and return an <code>ActionErrors</code> object that encapsulates any
347      * validation errors that have been found. If no errors are found, return
348      * <code>null</code> or an <code>ActionErrors</code> object with no
349      * recorded error messages.
350      *
351      * @param mapping The mapping used to select this instance
352      * @param request The servlet request we are processing
353      */

354     
355     public ActionErrors validate(ActionMapping mapping,
356     HttpServletRequest JavaDoc request) {
357         
358         ActionErrors errors = new ActionErrors();
359         
360         String JavaDoc submit = request.getParameter("submit");
361         //String type = request.getParameter("realmType");
362

363         // front end validation when save is clicked.
364
//if (submit != null) {
365
// the following fields are required.
366

367             if ((driver == null) || (driver.length() < 1)) {
368                 errors.add("driver",
369                 new ActionError("error.driver.required"));
370             }
371          
372             if ((roleNameCol == null) || (roleNameCol.length() < 1)) {
373                 errors.add("roleNameCol",
374                 new ActionError("error.roleNameCol.required"));
375             }
376
377             if ((userNameCol == null) || (userNameCol.length() < 1)) {
378                 errors.add("userNameCol",
379                 new ActionError("error.userNameCol.required"));
380             }
381
382              if ((passwordCol == null) || (passwordCol.length() < 1)) {
383                 errors.add("passwordCol",
384                 new ActionError("error.passwordCol.required"));
385             }
386             
387             if ((userTable == null) || (userTable.length() < 1)) {
388                 errors.add("userTable",
389                 new ActionError("error.userTable.required"));
390             }
391             
392             if ((roleTable == null) || (roleTable.length() < 1)) {
393                 errors.add("roleTable",
394                 new ActionError("error.roleTable.required"));
395             }
396             
397             if ((connectionName == null) || (connectionName.length() < 1)) {
398                 errors.add("connectionName",
399                 new ActionError("error.connectionName.required"));
400             }
401             
402             if ((connectionPassword == null) || (connectionPassword.length() < 1)) {
403                 errors.add("connectionPassword",
404                 new ActionError("error.connectionPassword.required"));
405             }
406             
407              if ((connectionURL == null) || (connectionURL.length() < 1)) {
408                 errors.add("connectionURL",
409                 new ActionError("error.connectionURL.required"));
410             }
411         //}
412

413         return errors;
414     }
415 }
416
Popular Tags