Changeset 29845


Ignore:
Timestamp:
2015-04-21T20:30:46+12:00 (9 years ago)
Author:
ak19
Message:

Modified gs3-server dialog to have an Allow External Connections checkbox to match with GS2. Affects org/greenstone/server code and server.properties file, greenstone.xml.in of tomcat, build.xml and build.properties

Location:
main/trunk/greenstone3
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.properties.in

    r28643 r29845  
    3030# default servlet to start with
    3131server.default.servlet=/library
     32# whether to make the greenstone pages publicly accessible or only to this machine
     33server.external.access=true
    3234
    3335# The context name of your GS3 digital library. By default this will be "greenstone3".
  • main/trunk/greenstone3/build.xml

    r29711 r29845  
    123123  <condition property="privileged.attribute" value="privileged='true'" else="">
    124124    <equals arg1="7" arg2="${tomcat.version.major}"/>
     125  </condition>
     126
     127  <!-- external access to the GS3 pages or not
     128       https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html -->
     129  <condition property="allowed.IPs"
     130         value=".*"
     131         else="(127\.0\.0\.1|::1|0:0:0:0:0:0:0:1)">
     132    <matches pattern="^(1|true|yes)$" string="${server.external.access}"/>
    125133  </condition>
    126134
     
    13421350        <filter token="gsdl3webhome" value="${web.home}"/>
    13431351        <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
    1344     <filter token="privilegedattribute" value ="${privileged.attribute}"/>
     1352    <filter token="privilegedattribute" value="${privileged.attribute}"/>
     1353    <filter token="allowedIPs" value="${allowed.IPs}"/>
    13451354      </filterset>
    13461355    </copy>
  • main/trunk/greenstone3/resources/java/server.properties

    r24480 r29845  
    22Server2Settings.Port=Apache port:
    33Server2Settings.URL=Library URL prefix:
    4 Server2Settings.ExternalAccess=Allow external connections
    54Server2Settings.AddressResolutionMethod=Address resolution method
    65Server2Settings.ResolveIP=Get local IP and resolve to a name
     
    2726ServerSettings.SettingChanged=The new settings will be available when you press Enter Library/Restart Library.
    2827ServerSettings.SettingsUnchangedPortOccupied=Unable to run the Greenstone server on port {0}. It appears to already be in use.
     28ServerSettings.ExternalAccess=Allow external connections
    2929
    3030ServerControl.EnterLibrary=Enter Library
  • main/trunk/greenstone3/resources/tomcat/greenstone3.xml.in

    r29722 r29845  
    2525         file. -->
    2626    <Manager pathname="SESSIONS.ser" />
     27
     28    <!-- Allow all machines or just this machine: 127.0.0.1 (IPv4) and 0:0:0:0:0:0:0:1 (IPv6, needed on windows)
     29         https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html -->
     30    <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="@allowedIPs@"/>
    2731</Context>
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseProperty.java

    r24207 r29845  
    88    public final String KEEPPORT;
    99    public final String START_BROWSER;
     10    public final String ALLOW_EXTERNAL_ACCESS;
    1011
    1112    public final String DEFAULT_SERVLET = "server.default.servlet";
     
    2223    public final String SERVER_SETTINGS;
    2324   
    24     protected BaseProperty(String version, String web_port, String autostart, String startbrowser, String keepport)
     25    protected BaseProperty(String version,
     26               String web_port,
     27               String autostart,
     28               String startbrowser,
     29               String keepport,
     30               String allowExternalAccess)
    2531    {
    2632    // property names
     
    3339    START_BROWSER = startbrowser;
    3440    KEEPPORT = keepport;
     41    ALLOW_EXTERNAL_ACCESS = allowExternalAccess;
    3542    }
    3643
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerSettings.java

    r25635 r29845  
    2222    protected JCheckBox autoEnter;
    2323    protected JCheckBox keepPortToggle;
     24    protected JCheckBox allowConnections;
    2425
    2526    protected JSpinner portNumber_spinner = null;
     
    3536    protected String browserPath = "";
    3637    protected boolean useDefaultBrowser = true;
     38    protected boolean externalaccess = false;
    3739
    3840    protected JDialog self;
     
    102104    keepPortToggle.setBackground(bg_color);
    103105
     106    boolean allowCons = false;
     107    String externalAccessStr = server.config_properties.getProperty(BaseServer.Property.ALLOW_EXTERNAL_ACCESS, "1").trim();
     108    allowConnections = new JCheckBox(server.dictionary.get("ServerSettings.ExternalAccess"), allowCons);
     109    if(externalAccessStr.equals("1") || externalAccessStr.equals("true")) {
     110        this.externalaccess = true;
     111        allowCons = true;
     112        allowConnections.setSelected(true);
     113    } else {
     114        allowConnections.setSelected(false);
     115    }
     116   
     117    allowConnections.setBackground(bg_color);
    104118
    105119    JButton save_button = new JButton(BaseServer.dictionary.get("ServerSettings.OK"));
     
    125139    port_panel.setBackground(bg_color);
    126140
    127     JPanel top_panel = new JPanel(new GridLayout(3,1));
     141    JPanel top_panel = new JPanel(new GridLayout(4,1));
    128142    top_panel.add(port_panel);
    129143    top_panel.add(keepPortToggle);
    130144    top_panel.add(autoEnter);
     145    top_panel.add(allowConnections);
    131146
    132147    JPanel comb_panel = createServletPanel();
     
    252267        }
    253268
     269        boolean oldExternalAccess = externalaccess;
     270        externalaccess = allowConnections.isSelected() ? true : false;
     271        if (oldExternalAccess != externalaccess) {
     272        has_changed = true;
     273        require_restart = true;
     274        server.reconfigRequired();
     275        } // else require_restart remains what it had been
    254276
    255277        // call subclass' onSave method, which may indicate (further) changes,
     
    287309       
    288310        // call the subclass' save() method to save custom elements
     311        // and to save externalAccess in a custom manner for both GS2 and GS3
    289312        save(scriptReadWrite, newFileLines);
    290313       
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server2Property.java

    r24465 r29845  
    99    // Initialising customised final variables
    1010    // Version number, WEB_PORT
    11     super("2", "portnumber", property_prefix+"autoenter", property_prefix+"start_browser", "keepport");
     11    super("2", "portnumber", property_prefix+"autoenter", property_prefix+"start_browser",
     12          "keepport", "externalaccess");
    1213    }
    1314
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server2Settings.java

    r29843 r29845  
    1717{
    1818    protected JComboBox prefix_combobox;
    19     protected JCheckBox allowConnections;
    2019    protected JRadioButton[] hostRadioButtons = new JRadioButton[4];
    2120
    2221    // 0 to 3: 0 is resolved (hostname) from local IP, 1 is local IP address, 2 is localhost, 3 is 127.0.0.1
    2322    protected int address_resolution_method = 2;
    24     protected int externalaccess = 0;
    2523
    2624    public Server2Settings(BaseServer server)
     
    3331    JPanel server2panel = new JPanel();
    3432    server2panel.setLayout(new BorderLayout());
    35 
    36     boolean allowCons = false;
    37     String externalAccess = server.config_properties.getProperty("externalaccess", "").trim();
    38     if(!externalAccess.equals("") && externalAccess.equals("1")) {
    39         this.externalaccess = 1;
    40         allowCons = true;
    41     }
    42     allowConnections = new JCheckBox(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".ExternalAccess"), allowCons);
    43     allowConnections.setBackground(bg_color);
    4433   
    4534    JPanel connect_panel = new JPanel(new GridLayout(4, 1));
     
    6756
    6857    JPanel comb_panel = new JPanel(new BorderLayout());
    69     comb_panel.add(allowConnections, BorderLayout.NORTH);
    7058    comb_panel.add(connect_panel, BorderLayout.CENTER);
    7159    return comb_panel;
     
    7563    {
    7664    // superclass detects changes to port and autoenter
    77     // handle changes to address_resolution_method and externalAccess/allowConnections here
     65    // handle changes to address_resolution_method here
    7866
    7967    boolean hasChanged = false;
     
    8775        server.reconfigRequired();
    8876        }
    89     }
    90 
    91     int oldExternalAccess = externalaccess;
    92     externalaccess = allowConnections.isSelected() ? 1 : 0;
    93     if (oldExternalAccess != externalaccess) {
    94         hasChanged = true;
    95         requireRestart = true;
    96         server.reconfigRequired();
    9777    }
    9878
     
    11696
    11797    // external access - onSave() would have updated this value
    118     newFileLines = scriptReadWrite.queryReplace(newFileLines, "externalaccess", Integer.toString(externalaccess));
     98    // Its possible values are specific to the version of Greenstone: 0 or 1 for GS2 (true or false for GS3)
     99    newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.ALLOW_EXTERNAL_ACCESS, externalaccess ? "1" : "0");
    119100   
    120101    // work out the host (default is address_resolution_method 2: localhost)
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3Property.java

    r24207 r29845  
    1010    // Version number, WEB_PORT, autoenter, startbrowser
    1111    // For GS3, the last two are controlled by the same property
    12     super("3", "tomcat.port", "server.auto.start", "server.auto.start", "server.keep.port");
     12    super("3", "tomcat.port", "server.auto.start", "server.auto.start",
     13          "server.keep.port", "server.external.access");
    1314    }
    1415
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3Settings.java

    r29728 r29845  
    105105    String newKeepPort = (new Boolean(keepPortToggle.isSelected())).toString();
    106106    newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.KEEPPORT, newKeepPort);
     107   
     108    // external access - BaseServerSettings.actionPerformed() would have updated this value
     109    // Its possible values are specific to the version of Greenstone: 0 or 1 for GS2 (true or false for GS3)
     110    newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.ALLOW_EXTERNAL_ACCESS, externalaccess ? "true" : "false");
    107111
    108112    String newServletDef = (String) servlet_combobox.getSelectedItem();
Note: See TracChangeset for help on using the changeset viewer.