Ignore:
Timestamp:
2012-03-28T15:45:03+13:00 (12 years ago)
Author:
ak19
Message:
  1. Updated txt2usersDB.java to compile again and to also work with usersDB2txt.java such that the output of running one becomes the exact input required by the other and vice-versa. So running usersDB2txt and then txt2usersDB on the txt file generated by the former, will generate a DB file that can be fed back into usersDB2txt which will once more produce an identical text output. 2. Created the ChangePwdUsersDB.java file which build.xml's new ant config-admin target calls to reset the admin password.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/txt2usersDB.java

    r16869 r25308  
    3838        dw.connectDatabase(args[1],false);
    3939        boolean delete_rows = dw.deleteAllUser();
     40        dw.closeDatabase();
    4041        if (!delete_rows){
    4142        System.out.println("Couldn't delete rows of the users table");
     
    4748        String accountstatus=null;
    4849        String comment=null;
     50        String email=null;
    4951        while ((str = in.readLine()) != null) {
    5052        //ystem.out.println(str);
    51         if (str.startsWith("<")){
     53       
     54        if(str.indexOf(" = ") != -1) { // works with DerbyWrapper.db2txt() and usersDB2txt.java. Fields listed as: USERNAME = admin
     55            String field=str.substring(0,str.indexOf(" = "));
     56            if (field.equalsIgnoreCase("email")){
     57            email=str.substring(str.indexOf(" = ")+3,str.length());
     58            }
     59            if (field.equalsIgnoreCase("comment")){
     60            comment=str.substring(str.indexOf(" = ")+3,str.length());
     61            }
     62            if (field.equalsIgnoreCase("status")){
     63            accountstatus=str.substring(str.indexOf(" = ")+3,str.length());
     64            }
     65            if (field.equalsIgnoreCase("groups")){
     66            groups=str.substring(str.indexOf(" = ")+3,str.length());
     67            }
     68            if (field.equalsIgnoreCase("password")){
     69            //password=dw.rot13(str.substring(str.indexOf(">")+1,str.length()));
     70            password=str.substring(str.indexOf(" = ")+3,str.length());
     71            }
     72            if (field.equalsIgnoreCase("username")){
     73            username=str.substring(str.indexOf(" = ")+3,str.length());
     74            }
     75        }       
     76        else if (str.startsWith("<")){ // fields listed as: <username>admin
    5277            String field=str.substring(1,str.indexOf(">"));
     78            if (field.equals("email")){
     79            email=str.substring(str.indexOf(">")+1,str.length());
     80            }
    5381            if (field.equals("comment")){
    5482            comment=str.substring(str.indexOf(">")+1,str.length());
    5583            }
    56             if (field.equals("enabled")){
     84            if (field.equals("enabled") || field.equals("status")){
    5785            accountstatus=str.substring(str.indexOf(">")+1,str.length());
    5886            }
     
    6189            }
    6290            if (field.equals("password")){
    63             password=dw.rot13(str.substring(str.indexOf(">")+1,str.length()));
     91            //password=dw.rot13(str.substring(str.indexOf(">")+1,str.length()));
     92            password=str.substring(str.indexOf(">")+1,str.length());
    6493            }
    6594            if (field.equals("username")){
     
    6796            }
    6897        }
    69         if (str.equals("----------------------------------------------------------------------")){
    70             if ((username!=null) && (password!=null) && (groups!=null) && (accountstatus!=null) && (comment!=null)){
     98        else if (str.equals("----------------------------------------------------------------------")
     99             || str.equals("-------------------------------------")) {         
     100           
     101            if ((username!=null) && (password!=null) && (groups!=null) && (accountstatus!=null) && (comment!=null) && (email!=null)) {
    71102            dw.connectDatabase(args[1],false);
    72             dw.addUser(username, password, groups, accountstatus, comment);
     103            dw.addUser(username, password, groups, accountstatus, comment, email);
    73104            username=null;
    74105            password=null;
     
    76107            accountstatus=null;
    77108            comment=null;
    78             dw.connectDatabase(args[1],false);
     109            email=null;
     110            //dw.connectDatabase(args[1],false); // should this be closeDatabase()????
     111            dw.closeDatabase();
     112            }
     113        }
     114        else { // encrypted passwords can span multiple lines for some reason
     115               // assume that is the case here
     116            if(password != null) {
     117            password = password + "\n" + str;
    79118            }
    80119        }
Note: See TracChangeset for help on using the changeset viewer.