Changeset 31860 for main

Show
Ignore:
Timestamp:
09.08.2017 16:48:21 (2 years ago)
Author:
ak19
Message:

The changes necessary for getting the new no_check_certificate checkbox to appear and work in GLI and get propagated to the perl code that launches wget. This checkbox controls whether wget is launched with the no-check-certificate flag to retrieve Https URLs despite lack of (valid) certificates.

Location:
main/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/classes/dictionary.properties

    r31720 r31860  
    10001000Preferences.Connection.ProgramCommand:Preview Command: 
    10011001Preferences.Connection.ProgramCommand_Tooltip:The launch command for the program used to view the collection preview. Remember to use %1 as the placeholder for the collection address, and to use speechmarks where necessary. 
     1002Preferences.Connection.No_Check_Certificate: No certificate checking for Https URLs # Disable Https security certificate checking? 
     1003Preferences.Connection.No_Check_Certificate_Tooltip:Tick to download from Https URLs even if they don't have a (valid) security certificate. 
    10021004Preferences.Connection.Proxy_Host:Proxy Host: 
    10031005Preferences.Connection.Proxy_Host_Tooltip:The address of your proxy server 
  • main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java

    r31831 r31860  
    106106    try { 
    107107        String [] env = null; 
    108         SafeProcess prcs = null;  
    109        
     108        SafeProcess prcs = null; 
     109         
    110110        if (Utility.isWindows()) { 
    111111        prcs = new SafeProcess(command); 
  • main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java

    r31852 r31860  
    571571        // redirect url (we do this step in order to avoid some unintuitive behaviour from wget) 
    572572        Download current_download = (Download)download_map.get(mode); 
     573         
     574        boolean noCheckCertificate = Configuration.get("general.no_check_certificate", true);        
     575        Argument no_check_cert_arg = current_download.getArgument("no_check_certificate"); 
     576        if(noCheckCertificate) { 
     577            no_check_cert_arg.setValue("true"); 
     578            no_check_cert_arg.setAssigned(true); 
     579        } else { 
     580            no_check_cert_arg.setValue("false"); 
     581            no_check_cert_arg.setAssigned(false); // only assigned Arguments have values 
     582        } 
     583 
    573584        Argument arg_url = current_download.getArgument("url"); 
    574585         
     
    576587            String url_str = arg_url.getValue();     
    577588             
    578             // No longer following URL redirects, since some of this has been taken care of by wget 
    579             // For the rest, assume the user will get the URL right that they want to download from 
    580             /* 
    581             String redirect_url_str = getRedirectURL(url_str); 
    582              
    583             // only update the Argument and its GUI ArgumentControl if the URL 
    584             // has in fact changed 
    585             if(!url_str.equals(redirect_url_str)) { 
    586             arg_url.setValue(redirect_url_str); 
    587             updateArgument(arg_url, redirect_url_str); 
    588             } 
    589             */ 
     589            // No longer following URL redirects, since some of this has been taken care of by wget 
     590            // For the rest, assume the user will get the URL right that they want to download from 
     591            /* 
     592              String redirect_url_str = getRedirectURL(url_str); 
     593               
     594              // only update the Argument and its GUI ArgumentControl if the URL 
     595              // has in fact changed 
     596              if(!url_str.equals(redirect_url_str)) { 
     597              arg_url.setValue(redirect_url_str); 
     598              updateArgument(arg_url, redirect_url_str); 
     599              } 
     600            */ 
    590601        } 
    591602         
     
    758769        // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the following can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this 
    759770        if (Utility.isWindows()) { 
    760               
    761            arg.setValue("true"); 
     771            
     772           arg.setValue("true"); // proxy_on argument 
    762773           arg.setAssigned(true); 
    763  
     774            
    764775           arg = current_download.getArgument("proxy_host"); 
    765776           arg.setValue(proxy_host); 
    766777           arg.setAssigned(true); 
    767  
     778            
    768779           arg = current_download.getArgument("proxy_port"); 
    769780           arg.setValue(proxy_port); 
    770781           arg.setAssigned(true); 
    771  
     782         
    772783           arg = current_download.getArgument("user_name"); 
    773784           arg.setValue(user_pass.substring(0, user_pass.indexOf("@"))); 
     
    822833        } 
    823834 
     835        boolean noCheckCertificate = Configuration.get("general.no_check_certificate", true); 
     836        Argument no_check_cert_arg = current_download.getArgument("no_check_certificate"); 
     837        if(noCheckCertificate) {         
     838        no_check_cert_arg.setValue("true"); 
     839        no_check_cert_arg.setAssigned(true); 
     840        } else { 
     841        no_check_cert_arg.setValue("false"); 
     842        no_check_cert_arg.setAssigned(false); // only assigned Arguments have values 
     843        } 
     844         
     845         
    824846        //str_url = getRedirectURL(str_url); // work out the real URL 
    825847 
  • main/trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r22831 r31860  
    7171    private JButton ok_button; 
    7272    private JCheckBox show_file_size_checkbox; 
     73    private JCheckBox no_check_certificate_checkbox; // Set no_check_certificate when retrieving Https URLs that have no (valid) certificate 
    7374    private JCheckBox use_proxy_checkbox; 
    7475    private JCheckBox view_extracted_metadata_checkbox; 
     
    318319        chdir_button.setEnabled(false); 
    319320    } 
     321 
     322    boolean no_check_cert_enabled = Configuration.get("general.no_check_certificate", true); // pass true to look in general rather than collection specific config file 
    320323     
    321324    boolean currently_enabled = Configuration.get("general.use_proxy", true); 
     
    323326    JPanel connection_pane = new JPanel(); 
    324327        connection_pane.setComponentOrientation(Dictionary.getOrientation()); 
     328    no_check_certificate_checkbox = new JCheckBox(Dictionary.get("Preferences.Connection.No_Check_Certificate")); 
     329    no_check_certificate_checkbox.setToolTipText(Dictionary.get("Preferences.Connection.No_Check_Certificate_Tooltip")); 
     330    no_check_certificate_checkbox.setSelected(no_check_cert_enabled); 
     331    no_check_certificate_checkbox.setComponentOrientation(Dictionary.getOrientation());         
     332    no_check_certificate_checkbox.setPreferredSize(ROW_SIZE); 
     333     
    325334    use_proxy_checkbox = new JCheckBox(Dictionary.get("Preferences.Connection.Use_Proxy")); 
    326335    use_proxy_checkbox.setSelected(currently_enabled); 
     
    360369     
    361370    // Connection 
     371    no_check_certificate_checkbox.addActionListener(new NoCheckCertificateListener()); 
    362372    use_proxy_checkbox.addActionListener(new UseProxyListener()); 
    363373    if (Gatherer.GS3) { 
     
    404414 
    405415    connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
    406     connection_pane.setLayout(new GridLayout(8,1,0,2)); 
     416    connection_pane.setLayout(new GridLayout(9,1,0,2)); 
    407417    connection_pane.add(program_pane); 
    408418    connection_pane.add(library_path_pane); 
     
    416426    connection_pane.add(collect_dir_pane); 
    417427 
     428    connection_pane.add(no_check_certificate_checkbox); 
    418429    connection_pane.add(use_proxy_checkbox); 
    419430    connection_pane.add(proxy_host_pane); 
     
    11191130    } 
    11201131 
     1132    private class NoCheckCertificateListener implements ActionListener { 
     1133    public void actionPerformed(ActionEvent event) { 
     1134        boolean isEnabled = no_check_certificate_checkbox.isSelected(); 
     1135        Configuration.set("general.no_check_certificate", true, isEnabled); 
     1136        boolean no_check_cert_enabled = Configuration.get("general.no_check_certificate", true); 
     1137    } 
     1138    } 
     1139     
    11211140    private class UseProxyListener 
    11221141    implements ActionListener { 
  • main/trunk/greenstone2/perllib/downloaders/WebDownload.pm

    r31857 r31860  
    4040use strict; # every perl program should have this! 
    4141no strict 'refs'; # make an exception so we can use variables as filehandles 
     42no strict 'subs'; 
     43use gsprintf 'gsprintf'; 
    4244 
    4345my $arguments =  
     
    117119    my $cmdWget = "-N -k -x --tries=2 $strWgetOptions $strOptions $cache_dir " .$self->{'url'}; 
    118120 
    119     #print STDOUT "\n@@@@ RUNNING WGET CMD: $cmdWget\n\n"; 
     121    #print STDOUT "\n@@@@ RUNNING WGET CMD: $cmdWget\n\n"; 
    120122     
    121123    # Download the web pages 
     
    194196     
    195197    if (!defined $strIdentifyText or $strIdentifyText eq ""  ){ 
    196         print STDERR "Server information is unavailable.\n";             
    197         if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) { # if proxying set, the settings may be wrong 
    198             print STDERR "Current proxy settings are:\n"; 
    199             print STDERR "- host=$self->{'proxy_host'}\n"; 
    200             print STDERR "- port=$self->{'proxy_port'}\n"; 
    201         } else { # else no proxy set, the user may need proxy settings 
    202             print STDERR "The external server might not be responding, or you might need to switch on proxy settings.\n"; 
    203         } 
    204         print STDERR "<<Finished>>\n"; 
    205          return;   
     198     
     199    print STDERR "Server information is unavailable.\n"; 
     200 
     201    if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) { # if proxying set, the settings may be wrong 
     202        &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxied_connect_failed_info}\n", $self->{'proxy_host'}, $self->{'proxy_port'}); 
     203    } else { # else no proxy set, the user may need proxy settings 
     204        &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxyless_connect_failed_info}\n"); 
     205    } 
     206     
     207    # with or without proxying set, getting server info may have failed if the URL was Https 
     208    # but the site had no valid certificate and no_check_certificate wasn't turned on 
     209    # suggest to the user to try turning it on 
     210    &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.connect_failed_info}\n"); 
     211     
     212    print STDERR "<<Finished>>\n"; 
     213    return;   
    206214    } 
    207215 
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r31856 r31860  
    7070    'type' => "string", 
    7171    'reqd' => "no", 
    72     'hiddengli' => "yes"}]; 
     72    'hiddengli' => "yes"}, 
     73      { 'name' => "no_check_certificate",  
     74    'desc' => "{WgetDownload.no_check_certificate}", 
     75    'type' => "flag", 
     76    'reqd' => "no", 
     77    'hiddengli' => "yes"} 
     78     ]; 
    7379 
    7480my $options = { 'name'     => "WgetDownload", 
     
    183189    } 
    184190 
    185     if($self->{'no_check_certificate'} && $self->{'url'} =~ m/^https\:/) { 
    186         $strOptions .= " --no-check-certificate "; 
    187     } 
     191    if($self->{'no_check_certificate'}) { #&& $self->{'url'} =~ m/^https\:/) { # URL may be http that gets redirected to https 
     192     
     193    $strOptions .= " --no-check-certificate "; 
     194    } 
    188195     
    189196    return $strOptions; 
  • main/trunk/greenstone2/perllib/gsprintf.pm

    r31419 r31860  
    7171sub gsprintf 
    7272{ 
     73    my ($handle, $text_string, @text_arguments) = @_;     
     74    _gsprintf($handle, $text_string, 0, @text_arguments); 
     75} 
     76 
     77sub gsprintf_multiline 
     78{ 
    7379    my ($handle, $text_string, @text_arguments) = @_; 
     80    _gsprintf($handle, $text_string, 1, @text_arguments); 
     81} 
     82 
     83sub _gsprintf 
     84{ 
     85    my ($handle, $text_string, $multiline, @text_arguments) = @_; 
    7486 
    7587    # Return unless the required arguments were supplied 
     
    8294    my $text_string_resolved = sprintf($text_string, @text_arguments); 
    8395 
     96    if($multiline) { # replace newlines 
     97    $text_string_resolved =~ s@\\n@\n@g; 
     98    } 
     99     
    84100    if ($freetext_xml_mode) { 
    85101    $text_string_resolved = make_freetext_xml_safe($text_string_resolved); 
    86102    } 
    87  
     103     
    88104    print $handle $text_string_resolved; 
    89105} 
    90106 
    91      
     107 
    92108 
    93109sub lookup_string 
  • main/trunk/greenstone2/perllib/strings.properties

    r31787 r31860  
    13361336WebDownload.html_only:Download only HTML files, and ignore associated files e.g images and stylesheets 
    13371337WebDownload.html_only_disp:Only HTML files 
     1338WebDownload.proxied_connect_failed_info:Current proxy settings are:\n- host=%s\n- port=%s 
     1339WebDownload.proxyless_connect_failed_info:- The external server might not be responding\n- or you might need to switch on proxy settings 
     1340WebDownload.connect_failed_info:- or try ticking No Certificate Checking for Https\nin File > Preferences > Connection 
    13381341 
    13391342WgetDownload.desc: Base class that handles calls to wget 
     
    13431346WgetDownload.user_name:User name 
    13441347WgetDownload.user_password:User password 
     1348WgetDownload.no_check_certificate:No check certificate 
    13451349 
    13461350Z3950Download.desc:A module for downloading from Z3950 repositories