source: greenstone3/trunk/src/java/org/greenstone/gsdl3/service/Authentication.java@ 14331

Last change on this file since 14331 was 14331, checked in by qq6, 17 years ago

create an etc dir under the site if the etc is not exiting

File size: 23.2 KB
Line 
1package org.greenstone.gsdl3.service;
2
3import org.greenstone.gsdl3.util.GSXML;
4import org.greenstone.gsdl3.util.GSPath;
5import org.greenstone.gsdl3.util.DerbyWrapper;
6import org.greenstone.gsdl3.util.UserQueryResult;
7import org.greenstone.gsdl3.util.UserTermInfo;
8import org.greenstone.gsdl3.util.GlobalProperties;
9
10import org.w3c.dom.Element;
11import org.w3c.dom.NodeList;
12
13import java.util.ArrayList;
14import java.util.Map;
15import java.util.Iterator;
16import java.util.Set;
17import java.util.HashMap;
18import java.util.Vector;
19import java.sql.SQLException;
20import org.apache.log4j.*;
21
22import java.net.InetAddress;
23import java.net.URLEncoder;
24import java.util.Properties;
25import java.util.Date;
26import java.util.regex.Pattern;
27import java.io.File;
28import java.io.UnsupportedEncodingException;
29//import javax.mail.*;
30//import javax.mail.internet.*;
31
32import java.awt.event.ActionEvent;
33import java.awt.event.ActionListener;
34import javax.swing.Timer;
35
36import org.apache.log4j.*;
37
38public class Authentication
39 extends ServiceRack {
40 //the services on offer
41 protected static final String AUTHENTICATION_SERVICE="Authentication";
42
43 /** constructor */
44 public Authentication()
45 { }
46
47 public boolean configure(Element info, Element extra_info)
48 {
49 logger.info("Configuring Authentication...");
50 this.config_info = info;
51
52 // set up Authentication service info - for now just has name and type
53 Element authentication_service= this.doc.createElement(GSXML.SERVICE_ELEM);
54 authentication_service.setAttribute(GSXML.TYPE_ATT, "authen");
55 authentication_service.setAttribute(GSXML.NAME_ATT, AUTHENTICATION_SERVICE);
56 this.short_service_info.appendChild(authentication_service);
57
58 return true;
59 }
60
61 protected Element getServiceDescription(String service_id, String lang, String subset)
62 {
63
64 Element authen_service=this.doc.createElement(GSXML.SERVICE_ELEM);
65
66 if (service_id.equals(AUTHENTICATION_SERVICE)) {
67 authen_service.setAttribute(GSXML.TYPE_ATT,"authen");
68 authen_service.setAttribute(GSXML.NAME_ATT, AUTHENTICATION_SERVICE);
69 } else {
70 return null;
71 }
72
73 if (subset==null || subset.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) {
74 authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(service_id, lang) ));
75 authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(service_id, lang)));
76 }
77 return authen_service;
78 }
79
80 protected String getServiceName(String service_id, String lang) {
81 return getTextString(service_id+".name", lang);
82 }
83
84 protected String getServiceSubmit(String service_id, String lang) {
85 return getTextString(service_id+".submit", lang);
86 }
87
88 protected String getServiceDescription(String service_id, String lang) {
89 return getTextString(service_id+".description", lang);
90 }
91
92 protected void addCustomParams(String service, Element param_list, String lang) {
93 }
94
95 protected void createParameter(String name, Element param_list, String lang) {
96 }
97
98 protected Element processAuthentication(Element request) throws SQLException, UnsupportedEncodingException{
99
100 // Create a new (empty) result message
101 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
102
103 result.setAttribute(GSXML.FROM_ATT, AUTHENTICATION_SERVICE);
104 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
105
106 String lang = request.getAttribute(GSXML.LANG_ATT);
107 // Get the parameters of the request
108 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
109
110 if (param_list == null) {
111 logger.error("AddUsers request had no paramList.");
112 return result; // Return the empty result
113 }
114
115 String aup=null; //Actions: ListUsers, AddUser, ModifyPassword, DeleteUser, Login
116 String un=""; //login user's name
117 String pw=""; //login user's password
118 String asn=""; //whether a user is authenticated
119 String uan=""; //whether a authentication for a particular action is needed
120 String cm=""; //whether the action is confirmed
121
122 String umun=""; //the new user name
123 String umpw=""; //user's new password
124 String umas=""; //user account status
125 String umgp=""; //user greoups
126 String umc=""; // comments for the user
127
128 String oumun=""; //the original user's name
129 String umpw1=""; //user's new password
130 String umpw2=""; //user's retyped new password
131
132 // get parameters from the request
133 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
134 for (int i=0; i<params.getLength();i++) {
135 Element param = (Element)params.item(i);
136 String p_name = param.getAttribute(GSXML.NAME_ATT);
137 String p_value = GSXML.getValue(param);
138
139 if (p_name.equals("aup")){
140 aup = URLEncoder.encode(p_value,"UTF-8");
141 }else if (p_name.equals("un")) {
142 un = URLEncoder.encode(p_value,"UTF-8");
143 }else if(p_name.equals("pw")) {
144 pw = URLEncoder.encode(p_value,"UTF-8");
145 }else if(p_name.equals("umun")) {
146 umun = URLEncoder.encode(p_value,"UTF-8");
147 }else if(p_name.equals("umpw")) {
148 umpw = URLEncoder.encode(p_value,"UTF-8");
149 }else if (p_name.equals("umas")){
150 umas = URLEncoder.encode(p_value,"UTF-8");
151 }else if (p_name.equals("umgp")){
152 umgp = URLEncoder.encode(p_value,"UTF-8");
153 }else if (p_name.equals("umc")){
154 umc = URLEncoder.encode(p_value,"UTF-8");
155 }else if (p_name.equals("asn")){
156 asn = URLEncoder.encode(p_value,"UTF-8");
157 }else if (p_name.equals("uan")){
158 uan = URLEncoder.encode(p_value,"UTF-8");
159 }else if (p_name.equals("cm")){
160 cm = URLEncoder.encode(p_value,"UTF-8");
161 }else if(p_name.equals("umpw1")) {
162 umpw1 = URLEncoder.encode(p_value,"UTF-8");
163 }else if(p_name.equals("umpw2")) {
164 umpw2 = URLEncoder.encode(p_value,"UTF-8");
165 }else if(p_name.equals("oumun")) {
166 oumun = URLEncoder.encode(p_value,"UTF-8");
167 }
168
169 }
170
171 // create a Authentication node put into the result
172 Element authen_node = this.doc.createElement(GSXML.AUTHEN_NODE_ELEM);
173 result.appendChild(authen_node);
174 // create a service node added into the Authentication node
175 Element service_node = this.doc.createElement(GSXML.SERVICE_ELEM);
176 authen_node.appendChild(service_node);
177 // add the authentication procedure to the service node
178 service_node.setAttribute("aup",aup);
179 // the user recordes got from the users table
180 UserQueryResult userQueryResult=null;
181
182 // check the usersDb database, if it isn't existing, create one and add a "admin" user
183 String usersDB_dir = this.site_home + File.separatorChar + "etc" + File.separatorChar + "usersDB";
184 DerbyWrapper derbyWrapper=new DerbyWrapper();
185 File usersDB_file =new File(usersDB_dir);
186 if (!usersDB_file.exists()){
187 String etc_dir = this.site_home + File.separatorChar + "etc";
188 File etc_file =new File(etc_dir);
189 if (!etc_file.exists()){
190 boolean success = etc_file.mkdir();
191 if (!success){
192 logger.error("Couldn't create the etc dir under "+this.site_home + ".");
193 return result;
194 }
195 }
196 derbyWrapper.connectDatabase(usersDB_dir,true);
197 derbyWrapper.createDatabase();
198 }
199
200 // Action: login
201 if (aup.equals("Login")){
202 if (uan.equals("")){
203 service_node.setAttribute("info","Login");
204 return result;
205 }
206
207 // if the current procedure requires authentication(uan=1),but the user hasn't been authenticated(asn=0),will ask the user to login first
208 if ((uan.equals("1") && asn.equals("0"))) {
209 if ((un.length()==0) && (pw.length()==0)){
210 service_node.setAttribute("asn","0");
211 service_node.setAttribute("info","Login");
212 return result;
213 }
214 if ((un.length()==0) || (pw.length()==0)){
215 service_node.setAttribute("asn","0");
216 service_node.setAttribute("info","Login");
217 service_node.setAttribute("err","un-pw-err");
218 return result;
219 }else{
220 derbyWrapper.connectDatabase(usersDB_dir, false);
221 userQueryResult=derbyWrapper.findUser(un,pw);
222 derbyWrapper.closeDatabase();
223 service_node.setAttribute(GSXML.NAME_ATT,"Authentication");
224
225 service_node.setAttribute("un",un);
226 service_node.setAttribute("pw",pw);
227 // service_node.setAttribute("asn",asn);
228 if (userQueryResult!=null && userQueryResult.getSize()<=0){
229 asn="0";//the user isn't a vaild user
230 service_node.setAttribute("asn","0");// either unsername or password is wrong
231 service_node.setAttribute("err","un-pw-err");
232 service_node.setAttribute("info","Login");
233 return result;
234 }else{
235 // asn="1"; //the user is a member of the "administrator" group
236 Vector userInfo=userQueryResult.users_;
237 String groups=((UserTermInfo)userInfo.get(0)).groups_;
238 String accountstatus=((UserTermInfo)userInfo.get(0)).accountstatus_;
239 String[] groups_array=groups.split(",");
240 for (int i=0; i<groups_array.length;i++){
241 if ((groups_array[i].trim().toLowerCase()).equals("administrator")){
242 if (accountstatus.trim().equals("true")){
243 asn="1";
244 service_node.setAttribute("asn","1");
245 break;
246 }
247 }
248 }
249 if (!asn.equals("1")){
250 asn="2";
251 service_node.setAttribute("asn","2");//the user is authenticated
252 }
253 }
254 }
255 }
256 //asn=0 couldn't find the user
257 if (asn.equals("0")){
258 service_node.setAttribute("info","Login");
259 service_node.setAttribute("err","not-authen");
260 return result;
261 }
262 //asn!=0 This is a valid user
263 if (!asn.equals("0")){
264 service_node.setAttribute("info","Login");
265 service_node.setAttribute("un",un);
266 service_node.setAttribute("pw",pw);
267 service_node.setAttribute("asn",asn);
268 return result;
269 }
270 }
271
272 //Action: listuser
273 if (aup.equals("ListUsers")){
274 if (asn.equals("") && un.equals("")){
275 service_node.setAttribute("info","Login");
276 return result;
277 }
278
279 //valid users can't list all users because they aren't in the administrator group(asn=2)
280 if (asn.equals("2")){
281 service_node.setAttribute("info","Login");
282 service_node.setAttribute("err","no-permission");
283 service_node.setAttribute("un",un);
284 service_node.setAttribute("asn",asn);
285 return result;
286 }
287 //valid users are in the administrator group, they can list all users(asn=1)
288 if (asn.equals("1")){
289 derbyWrapper.connectDatabase(usersDB_dir, false);
290 userQueryResult=derbyWrapper.findUser(null,null);
291 derbyWrapper.closeDatabase();
292 service_node.setAttribute(GSXML.NAME_ATT,"Authentication");
293 service_node.setAttribute("un",un);
294 service_node.setAttribute("asn",asn);
295
296 if (userQueryResult!=null && userQueryResult.getSize()>0){
297 service_node.setAttribute("info","all-un"); // got a user list
298 Element user_node=getUserNode(userQueryResult);
299 service_node.appendChild(user_node);
300 return result;
301 }else {
302 service_node.setAttribute("err","no-un"); // no user returned
303 return result;
304 }
305 }
306 }
307
308 //Action : adduder
309 if (aup.equals("AddUser")){
310 if (asn.equals("") && un.equals("")){
311 service_node.setAttribute("info","Login");
312 return result;
313 }
314 //valid users can't add a new user because they aren't in the administrator group(asn=2)
315 if (asn.equals("2")){
316 service_node.setAttribute("info","Login");
317 service_node.setAttribute("err","no-permission");
318 service_node.setAttribute("un",un);
319 service_node.setAttribute("pw",pw);
320 service_node.setAttribute("asn",asn);
321 return result;
322 }
323 //valid users are in the administrator group, they can add a new user(asn=1)
324 if (asn.equals("1")){
325 service_node.setAttribute(GSXML.NAME_ATT,"Authentication");
326 service_node.setAttribute("un",un);
327 service_node.setAttribute("pw",pw);
328 service_node.setAttribute("asn",asn);
329
330 if (umun.length()==0 && umpw.length()==0 && umgp.length()==0 && umas.length()==0 && umc.length()==0){
331 service_node.setAttribute("info","adduser_interface");
332 return result;
333 }
334
335 //check the strings of username and password
336 if ((umun==null) || (umun.length()<2) || (umun.length()>30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+",umun)))){
337 service_node.setAttribute("err","un-err"); //the input username string is illegal
338 service_node.setAttribute("info","adduser_interface");
339 return result;
340 }
341
342 if ((umpw==null) || (umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){
343 service_node.setAttribute("err","pw-err"); //the input passwrod string is illegal
344 service_node.setAttribute("info","adduser_interface");
345 return result;
346 }
347
348 // add the new users into the users table
349 umgp=umgp.replaceAll(" ","");//get rid of the space of the groups string
350 derbyWrapper.connectDatabase(usersDB_dir, false);
351 String add_user=derbyWrapper.addUser(umun,umpw,umgp,umas,umc);
352 if (add_user.equals("succeed")){
353 userQueryResult=derbyWrapper.findUser(null,null);
354 derbyWrapper.closeDatabase();
355 service_node.setAttribute("info","all-un"); // return a list of all users if the user has been added
356 Element user_node=getUserNode(userQueryResult);
357 service_node.appendChild(user_node);
358 return result;
359 }else{
360 derbyWrapper.closeDatabase();
361 service_node.setAttribute("err",add_user);// return the error message if the user couldn't be added
362 return result;
363 }
364 }
365 }
366
367 //Action: edituser
368 if (aup.equals("EditUser")){
369 derbyWrapper.connectDatabase(usersDB_dir, false);
370 service_node.setAttribute(GSXML.NAME_ATT,"Authentication");
371 service_node.setAttribute("un",un);
372 service_node.setAttribute("pw",pw);
373 service_node.setAttribute("asn",asn);
374
375 //Get the user's info from the database
376 if (cm.length()==0){
377 service_node.setAttribute("info","edituser-interface");
378 userQueryResult=derbyWrapper.findUser(umun,null);
379 derbyWrapper.closeDatabase();
380 Vector userInfo=userQueryResult.users_;
381 String username=((UserTermInfo)userInfo.get(0)).username_;
382 String password=((UserTermInfo)userInfo.get(0)).password_;
383 String groups=((UserTermInfo)userInfo.get(0)).groups_;
384 String accountstatus=((UserTermInfo)userInfo.get(0)).accountstatus_;
385 String comment=((UserTermInfo)userInfo.get(0)).comment_;
386
387 service_node.setAttribute("oumun",oumun);
388 service_node.setAttribute("umun",username);
389 service_node.setAttribute("umpw",password);
390 service_node.setAttribute("umgp",groups);
391 service_node.setAttribute("umas",accountstatus);
392 service_node.setAttribute("umc",comment);
393 return result;
394 }
395
396 //Commit the modified user's info to the database
397 if (cm.toLowerCase().equals("submit")){
398 if (oumun.equals(umun)){// the user's name hasn't been changed, update the user's info
399 if (umpw.length()==0){
400 derbyWrapper.modifyUserInfo(umun,null,umgp,umas,umc);
401 userQueryResult=derbyWrapper.findUser(null,null);
402 derbyWrapper.closeDatabase();
403 service_node.setAttribute("info","all-un"); // the user's info has been updated, return a list of all users
404 Element user_node=getUserNode(userQueryResult);
405 service_node.appendChild(user_node);
406 return result;
407 }else{
408 if ((umpw.length()==0) || (umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){
409 service_node.setAttribute("err","umpw-err"); //the input passwrod string is illegal
410 service_node.setAttribute("info","edituser-interface");
411 service_node.setAttribute("umun",umun);
412 service_node.setAttribute("umpw",umpw);
413 service_node.setAttribute("umgp",umgp);
414 service_node.setAttribute("umas",umas);
415 service_node.setAttribute("umc",umc);
416 service_node.setAttribute("oumun",oumun);
417 return result;
418 }
419 umgp=umgp.replaceAll(" ","");// get rid of the space
420 derbyWrapper.modifyUserInfo(umun,umpw,umgp,umas,umc);
421 userQueryResult=derbyWrapper.findUser(null,null);
422 derbyWrapper.closeDatabase();
423 service_node.setAttribute("info","all-un"); // if the new user has been added successfully, return a list of all users
424 Element user_node=getUserNode(userQueryResult);
425 service_node.appendChild(user_node);
426 return result;
427 }
428 }
429 // The user's name has been changed, add a new user record to the database
430 else{
431 if ((umun.length()==0) || (umun.length()<2) || (umun.length()>30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+",umun)))){
432 service_node.setAttribute("err","umun-err"); //the input username string is illegal
433 service_node.setAttribute("umun",umun);
434 service_node.setAttribute("umpw",umpw);
435 service_node.setAttribute("umgp",umgp);
436 service_node.setAttribute("umas",umas);
437 service_node.setAttribute("umc",umc);
438 service_node.setAttribute("oumun",oumun);
439 service_node.setAttribute("info","edituser-interface");
440 return result;
441 }
442 if (umpw.length()==0){
443 service_node.setAttribute("err","ini-umpw-err"); //the input passwrod string is illegal
444 service_node.setAttribute("info","edituser-interface");
445 service_node.setAttribute("umun",umun);
446 service_node.setAttribute("umpw",umpw);
447 service_node.setAttribute("umgp",umgp);
448 service_node.setAttribute("umas",umas);
449 service_node.setAttribute("umc",umc);
450 service_node.setAttribute("oumun",oumun);
451 return result;
452 }
453 if ((umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){
454 service_node.setAttribute("err","umpw-err"); //the input passwrod string is illegal
455 service_node.setAttribute("info","edituser-interface");
456 service_node.setAttribute("umun",umun);
457 service_node.setAttribute("umpw",umpw);
458 service_node.setAttribute("umgp",umgp);
459 service_node.setAttribute("umas",umas);
460 service_node.setAttribute("umc",umc);
461 service_node.setAttribute("oumun",oumun);
462 return result;
463 }
464 umgp=umgp.replaceAll(" ","");// get rid of the space
465 derbyWrapper.addUser(umun,umpw,umgp,umas,umc);
466 userQueryResult=derbyWrapper.findUser(null,null);
467 derbyWrapper.closeDatabase();
468 service_node.setAttribute("info","all-un"); // if the new user has been added successfully, return a list of all users
469 Element user_node=getUserNode(userQueryResult);
470 service_node.appendChild(user_node);
471 return result;
472 }
473 }
474
475 if (cm.toLowerCase().equals("cancel")){
476 userQueryResult=derbyWrapper.findUser(null,null);
477 derbyWrapper.closeDatabase();
478 service_node.setAttribute("info","all-un"); // if the new user has been added successfully, return a list of all users
479 Element user_node=getUserNode(userQueryResult);
480 service_node.appendChild(user_node);
481 return result;
482 }
483 }
484
485 //Action: modifypassword
486 if (aup.equals("ModifyPassword")){
487 if (un.equals("")){
488 service_node.setAttribute("info","Login");
489 return result;
490 }
491
492 derbyWrapper.connectDatabase(usersDB_dir, false);
493 service_node.setAttribute(GSXML.NAME_ATT,"Authentication");
494 service_node.setAttribute("un",un);
495 service_node.setAttribute("asn",asn);
496
497 userQueryResult=derbyWrapper.findUser(un,null);
498 Vector userInfo=userQueryResult.users_;
499 pw=((UserTermInfo)userInfo.get(0)).password_;
500
501 if ((umpw1.length()==0) && (umpw2.length()==0) && (umpw.length()==0)){
502 service_node.setAttribute("info","modify_interface");// call the interface of the modifying password
503 derbyWrapper.closeDatabase();
504 return result;
505 }
506
507 if (!pw.equals(umpw) && umpw.length()>0){
508 service_node.setAttribute("info","modify_interface");
509 service_node.setAttribute("err","pw-umpw-nm-err");//if the original password is not match
510 derbyWrapper.closeDatabase();
511 return result;
512 }
513
514 if ((umpw1.length()==0) || (umpw2.length()==0)){
515 service_node.setAttribute("info","modify_interface");
516 service_node.setAttribute("err","umpw1-umpw2-null-err");//if one of the password strings is none,return the err info back
517 derbyWrapper.closeDatabase();
518 return result;
519 }
520
521 if(!umpw1.equals(umpw2)){
522 service_node.setAttribute("info","modify_interface");
523 service_node.setAttribute("err","umpw1-umpw2-nm-err");//if one of the password strings is none,return the err info back
524 derbyWrapper.closeDatabase();
525 return result;
526 }
527
528 if (umpw.length()==0){
529 service_node.setAttribute("info","modify_interface");
530 service_node.setAttribute("err","umpw-null-err");//if one of the password strings is none,return the err info back
531 derbyWrapper.closeDatabase();
532 return result;
533 }
534 //check the new password and the retyped password
535 if ((umpw1==null) || (umpw1.length()<3) || (umpw1.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw1)))){
536 service_node.setAttribute("info","modify_interface");
537 service_node.setAttribute("err","umpw1-err");// the new password is illegal
538 derbyWrapper.closeDatabase();
539 return result;
540 }
541
542 if ((umpw2==null) || (umpw2.length()<3) || (umpw2.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw2)))){
543 service_node.setAttribute("info","modify_interface");
544 service_node.setAttribute("err","umpw2-err"); // the retyped password is illegal
545 derbyWrapper.closeDatabase();
546 return result;
547 }
548 String modify_user_info=derbyWrapper.modifyUserInfo(un,umpw,null,null,null);
549 if (modify_user_info.equals("succeed")){
550 service_node.setAttribute("err","");// the passsword has been changed successfully
551 derbyWrapper.closeDatabase();
552 return result;
553 }else{
554 service_node.setAttribute("err",modify_user_info);// return the error message of the pasword couldn't be modified
555 derbyWrapper.closeDatabase();
556 return result;
557 }
558
559 }
560
561 //Action: deleteuser
562 if (aup.equals("DeleteUser")){
563 derbyWrapper.connectDatabase(usersDB_dir, false);
564 service_node.setAttribute("un",un);
565 service_node.setAttribute("pw",pw);
566 service_node.setAttribute("asn",asn);
567 service_node.setAttribute("umun",umun);
568 if (cm.equals("yes")){
569 String delete_user=derbyWrapper.deleteUser(umun);
570 if (delete_user.equals("succeed")){
571 service_node.setAttribute("err","");
572 userQueryResult=derbyWrapper.findUser(null,null);
573 service_node.setAttribute("info","all-un"); // return a list of all users
574 Element user_node=getUserNode(userQueryResult);
575 service_node.appendChild(user_node);
576 }else{
577 service_node.setAttribute("err",delete_user);//return the error message
578 derbyWrapper.closeDatabase();
579 return result;
580 }
581 }else if (cm.equals("no")){
582 service_node.setAttribute("err","");
583 userQueryResult=derbyWrapper.findUser(null,null);
584 service_node.setAttribute("info","all-un"); // return a list of all users
585 Element user_node=getUserNode(userQueryResult);
586 service_node.appendChild(user_node);
587 derbyWrapper.closeDatabase();
588 return result;
589 }else{
590 service_node.setAttribute("info","confirm");
591 derbyWrapper.closeDatabase();
592 return result;
593 }
594 }
595
596 return result;
597 }
598
599 private Element getUserNode(UserQueryResult userQueryResult){
600 Element user_list_node= this.doc.createElement(GSXML.USER_NODE_ELEM+"List");
601
602 Vector userInfo=userQueryResult.users_;
603
604 for (int i=0; i<userQueryResult.getSize(); i++){
605 Element user_node= this.doc.createElement(GSXML.USER_NODE_ELEM);
606 String username=((UserTermInfo)userInfo.get(i)).username_;
607 String password=((UserTermInfo)userInfo.get(i)).password_;
608 String groups=((UserTermInfo)userInfo.get(i)).groups_;
609 String accountstatus=((UserTermInfo)userInfo.get(i)).accountstatus_;
610 String comment=((UserTermInfo)userInfo.get(i)).comment_;
611 user_node.setAttribute("umun",username);
612 user_node.setAttribute("umpw",password);
613 user_node.setAttribute("umgp",groups);
614 user_node.setAttribute("umas",accountstatus);
615 user_node.setAttribute("umc",comment);
616
617 user_list_node.appendChild(user_node);
618 }
619 return user_list_node;
620 }
621
622}
623
Note: See TracBrowser for help on using the repository browser.