Changeset 32430

Show
Ignore:
Timestamp:
06.09.2018 22:34:17 (8 months ago)
Author:
ak19
Message:

solr should only be accessible locally (from localhost, specifically 127.0.0.1) which means over http. This conflicted with the previous design of the properties file for working with http and/or https. Now we have tomcat.port.https and localhost.port.http, both always set. In place of server.protocol that used to contain the default protocol, we now have server.protocols which can be set to a comma separated list of one or both of http and https. Drastic restructuring followed. I think I've tested all but https certification stuff.

Location:
gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java

    r32419 r32430  
    9696            Properties globalProperties = new Properties(); 
    9797            globalProperties.load(Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream("global.properties")); 
     98             
     99            /* 
    98100            String host = globalProperties.getProperty("tomcat.server", "localhost"); 
    99101            //String port = globalProperties.getProperty("tomcat.port.http", "8383"); 
     
    107109            String portStr = port.equals("80") ? "" : ":"+port; 
    108110            solr_servlet_base_url = protocol+"://"+host+portStr+"/"+solrContext; 
     111            */ 
     112 
     113            // The solr servlet is only accessible locally (from "localhost",  specifically 127.0.0.1). 
     114            // for security reasons, as we don't want non librarian users 
     115            // to go to the solr servlet and delete solr cores or something. 
     116            // The security Valve element in the tomcat solr.xml context file restricts 
     117            // access to 127.0.0.1, but here we ensure that the solr URL is the local http one 
     118            // and not any https with domain name and https port. 
     119            // Note that we use 127.0.0.1 instead of literally "localhost" since localhost is unsafe 
     120            ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(globalProperties); // can throw Exception 
     121            String solrContext = globalProperties.getProperty("solr.context", "solr"); 
     122            solr_servlet_base_url = protocolPortProps.getLocalHttpBaseAddress()+"/"+solrContext; 
     123 
    109124        } catch(Exception e) { 
    110125            logger.error("Error reading greenstone's tomcat solr server properties from global.properties", e); 
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/SolrSearch.java

    r32419 r32430  
    4646        Properties globalProperties = new Properties(); 
    4747        globalProperties.load(Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream("global.properties")); 
     48 
     49        /* 
    4850        String host = globalProperties.getProperty("tomcat.server", "localhost"); 
    4951        //String port = globalProperties.getProperty("tomcat.port.http", "8383"); 
     
    5658        String portStr = port.equals("80") ? "" : ":"+port; 
    5759        solr_servlet_base_url = protocol+"://"+host+portStr+"/"+solrContext; 
     60        */ 
     61 
     62        // The solr servlet is only accessible locally (from "localhost",  specifically 127.0.0.1). 
     63        // for security reasons, as we don't want non librarian users 
     64        // to go to the solr servlet and delete solr cores or something. 
     65        // The security Valve element in the tomcat solr.xml context file restricts 
     66        // access to 127.0.0.1, but here we ensure that the solr URL is the local http one 
     67        // and not any https with domain name and https port. 
     68        // Note that we use 127.0.0.1 instead of literally "localhost" since localhost is unsafe 
     69        ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(globalProperties); // can throw an Exception 
     70        String solrContext = globalProperties.getProperty("solr.context", "solr"); 
     71        solr_servlet_base_url = protocolPortProps.getLocalHttpBaseAddress()+"/"+solrContext; 
    5872    } catch(Exception e) { 
    5973        logger.error("Error reading greenstone's tomcat solr server properties from global.properties", e);