Changeset 31843


Ignore:
Timestamp:
2017-08-02T20:17:30+12:00 (7 years ago)
Author:
ak19
Message:
  1. Adding new Java class URLConnectionManager to get an (Http)URLConnection depending on whether you're using a proxy or not, whether the URL is over Http or Https, and whether to set the no_check_certificate setting for Https URLs. Additional methods to set or unset this flag globally on all subsequent URL connections. 2. DownloadPane.getRedirectURL() now calls this and avoids the SSLHandShakeException discovered on Toro yesterday: not just wget but also Java code that makes a URL connection to an Https site that does not have a valid certificate will need to have no_check_certificate turned on if we want to download from there. Even if getRedirectURL() is found to no longer be useful, the new class URLConnectionManager is reusable. 4. Adding GS copyright header to SafeProcess.java.
Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r31839 r31843  
    5555import org.greenstone.gatherer.util.StaticStrings;
    5656import org.greenstone.gatherer.util.Utility;
     57import org.greenstone.gatherer.download.URLConnectionManager;
    5758import org.greenstone.gatherer.download.Download;
    5859import org.greenstone.gatherer.download.DownloadScrollPane;
     
    616617    if(url_str.startsWith("http:") || url_str.startsWith("https:")) { // only test http urls
    617618        try {
    618         URL url = new URL(url_str);
    619         if(this.proxyObject == null) {
    620             connection = (HttpURLConnection)url.openConnection(); //new HttpURLConnection(url);
    621         } else {
    622             connection = (HttpURLConnection)url.openConnection(proxyObject);
    623         }
     619        // URLConnectionManager class has special handling for https URLs,
     620        // so you can control whether you want it to check an HTTPS site's security certificates for you or not
     621        boolean noCheckCertificates = true;
     622        connection = (HttpURLConnection)URLConnectionManager.getConnection(url_str, this.proxyObject, noCheckCertificates);
     623       
    624624        // don't let it automatically follow redirects, since we want to
    625625        // find out whether we are dealing with redirects in the first place
     
    700700    }
    701701
    702    
     702    // TODO: Still need to read up on and test how to set wget proxy on windows
     703    // Need to be on a windows machine that requires proxy, and get wget to work on cmdline
     704    // If that works, then need to check https URLS also work.
     705    // See https://superuser.com/questions/526710/how-to-set-http-proxy-address-for-wget-under-windows
    703706    private boolean checkProxy(){
    704707     
  • main/trunk/gli/src/org/greenstone/gatherer/util/SafeProcess.java

    r31817 r31843  
     1/**
     2 *#########################################################################
     3 *
     4 * A component of the Gatherer application, part of the Greenstone digital
     5 * library suite from the New Zealand Digital Library Project at the
     6 * University of Waikato, New Zealand.
     7 *
     8 * Author: Greenstone Digital Library, University of Waikato, except where indicated
     9 *
     10 * Copyright (C) 1999 New Zealand Digital Library Project
     11 *
     12 * This program is free software; you can redistribute it and/or modify
     13 * it under the terms of the GNU General Public License as published by
     14 * the Free Software Foundation; either version 2 of the License, or
     15 * (at your option) any later version.
     16 *
     17 * This program is distributed in the hope that it will be useful,
     18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 * GNU General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU General Public License
     23 * along with this program; if not, write to the Free Software
     24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     25 *########################################################################
     26 */
    127package org.greenstone.gatherer.util;
    228
Note: See TracChangeset for help on using the changeset viewer.