Changeset 30055 for main


Ignore:
Timestamp:
2015-07-24T22:48:03+12:00 (9 years ago)
Author:
ak19
Message:

Fixing bug in GS3 installer that didn't use the longer password provided, despite the installer now allowing more than 8. The problem was bigger and manifold. 1. Fixed ModifyUsersDB to allow up to and incl 20 chars instead of 8. 2. Fixed the DerbyWrapper classes since the ant config-admin and config-user tasks had stopped working when global.properties was consulted for the derbyserver name and port. Now providing fallbacks again for the installer. 3. build.xml may no longer need to stop tomcat then modify the derby db and then start tomcat again because we're no longer using an embedded derby, but because we're using a networked derby, modifying the usersdb now didn't work unless greenstone (actually derby) was running. Changed the config targets to allow modifying admin and user data even if greenstone is not running, by making the update-userdb target that's called by these two tasks ensure the derbyserver is running before modifying the userdb, and stopping it if it was started up by the target.

Location:
main/trunk/greenstone3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.xml

    r30038 r30055  
    18321832    But you can do: echo mypassword | ant config-admin -->
    18331833  <target name="config-admin" description="Reset admin password">
    1834     <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-8 characters):&gt;">
     1834    <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-20 characters):&gt;">
    18351835      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
    18361836    </input>
     
    18501850  <target name="get-user-data" description="Get user details">
    18511851    <input addproperty="user.username" message="Username:&gt;"/>
    1852     <input addproperty="user.password" defaultvalue="" message="Password (3-8 characters):&gt;">
     1852    <input addproperty="user.password" defaultvalue="" message="Password (3-20 characters):&gt;">
    18531853      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
    18541854    </input>
     
    18591859  </target>
    18601860
    1861 <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
    1862     See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
    1863     But you can do: echo mypassword | ant config-admin -->
    1864   <target name="update-userdb" description="Add or modify users" depends="check-tomcat-running">
     1861  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
     1862       See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
     1863       But you can do: echo mypassword | ant config-admin -->
     1864  <target name="update-userdb" description="Add or modify users" depends="start-derby">
    18651865
    18661866    <!--
     
    18701870     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
    18711871     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" -->
    1872     <!--
    1873     <if>
    1874       <bool>
    1875     <istrue value="${tomcat.isrunning}"/>
    1876       </bool>
    1877       <antcall target="stop-tomcat"/>
    1878     </if>
    1879     -->
     1872   
     1873    <!-- Need the derby networked server to be running in order to modify the usersDB.
     1874     The start-derby task will check if derby is already running (if not, ${derby.isstarted} will
     1875     be false) and will only start up networked derby if it is not already running.
     1876     The ${derby.isstarted} property is set by the depends-target "start-derby", since it won't
     1877     set the property if called with antcall (like launching in a subshell). Have to use 'depends'.
     1878     We'll check ${derby.isstarted} at the end to stop derby again if we had to start it up now.-->
     1879    <!--<antcall target="start-derby"/>-->
     1880
     1881    <!-- wait a max of 5 seconds for the derbyserver to have started up -->
     1882    <waitfor maxwait="5" maxwaitunit="second">
     1883      <socket server="${derby.server}" port="${derby.server.port}"/>
     1884    </waitfor>
    18801885
    18811886    <!--<echo>${admin.password}</echo>--> <!-- for testing -->
     
    18901895      <arg value="email=${user.email}"/>
    18911896    </java>
    1892    
    1893     <!-- run tomcat again if it used to be running -->
    1894     <!--
     1897
     1898    <!-- Need to stop networked derby again if we ran it for this target with the depends=start-derby call.
     1899     The test here is for <not>derby.isstarted</not>, as the property would be the same as before
     1900     derby was started, since properties are immutable within a single ant command. -->
    18951901    <if>
    18961902      <bool>
    1897     <istrue value="${tomcat.isrunning}"/>
    1898     </bool>
    1899       <antcall target="force-start-tomcat"/>
    1900     </if>
    1901     -->
     1903    <not><istrue value="${derby.isstarted}"/></not>
     1904      </bool>
     1905      <antcall target="force-stop-derby"/>
     1906    </if>
     1907
    19021908  </target>
    19031909
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/sql/derby/DerbySQLServer.java

    r30043 r30055  
    1212public class DerbySQLServer implements SQLServer{
    1313   
    14     static final String PORT = GlobalProperties.getProperty("derby.server.port");//, "1527");
    15     static final String DERBYSERVER = GlobalProperties.getProperty("derby.server");//, "localhost");
     14    static final String PORT = GlobalProperties.getProperty("derby.server.port", "1527");
     15    static final String DERBYSERVER = GlobalProperties.getProperty("derby.server", "localhost");
    1616    static final String PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527";
    1717    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java

    r30043 r30055  
    3535public class DerbyWrapper
    3636{
    37     static final String PORT = GlobalProperties.getProperty("derby.server.port");//, "1527");
    38     static final String DERBYSERVER = GlobalProperties.getProperty("derby.server");//, "localhost");
     37    static final String PORT = GlobalProperties.getProperty("derby.server.port", "1527");
     38    static final String DERBYSERVER = GlobalProperties.getProperty("derby.server", "localhost");
    3939    static final String PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527";
    4040    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ModifyUsersDB.java

    r29467 r30055  
    2727public class ModifyUsersDB
    2828{
     29    public static int PWD_MIN_LENGTH = 3;
     30    public static int PWD_MAX_LENGTH = 20;
    2931
    3032    public static void main(String[] args) throws SQLException
     
    4951
    5052        // If the user specifically sets any of the fields on the cmdline, they'll be overwritten in the db,
    51         // even if the user had set them to empty. Except the password which must be between 3 and 8 characters.
     53        // even if the user had set them to empty. Except the password which must be between PWD_MIN_LENGTH and PWD_MAX_LENGTH characters.
    5254        for (int i = 2; i < args.length; i++)
    5355        {
     
    5658                password = args[i].substring("password=".length());
    5759
    58                 if (password.length() < 3 || password.length() > 8)
     60                if (password.length() < PWD_MIN_LENGTH || password.length() > PWD_MAX_LENGTH)
    5961                {
    6062                    if (!password.equals(""))
    6163                    {
    62                         System.out.println("Password not updated. It should be between 3 and 8 characters (inclusive).");
     64                        System.out.println("Password not updated. It should be between " + PWD_MIN_LENGTH + " and " + PWD_MAX_LENGTH + " characters (inclusive).");
    6365                    }
    6466                }
Note: See TracChangeset for help on using the changeset viewer.