Annotation of loncom/configuration/SSL.pm, revision 1.3

1.1       raeburn     1: # The LearningOnline Network with CAPA
                      2: # Checksum installed LON-CAPA modules and some configuration files
                      3: #
1.3     ! raeburn     4: # $Id: SSL.pm,v 1.2 2016/08/01 13:55:05 raeburn Exp $
1.1       raeburn     5: #
                      6: # The LearningOnline Network with CAPA
                      7: #
                      8: # Copyright Michigan State University Board of Trustees
                      9: #
                     10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     11: #
                     12: # LON-CAPA 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: # LON-CAPA 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 LON-CAPA; if not, write to the Free Software
                     24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     25: #
                     26: # /home/httpd/html/adm/gpl.txt
                     27: #
                     28: # http://www.lon-capa.org/
                     29: #
                     30: 
                     31: package LONCAPA::SSL;
                     32: use strict;
                     33: use lib '/home/httpd/lib/perl/';
                     34: use Apache::lonlocal();
                     35: use Apache::lonnet();
                     36: use Apache::loncommon();
                     37: use Apache::lonhtmlcommon();
                     38: use LONCAPA; 
                     39: 
                     40: sub print_certstatus {
                     41:     my ($servers,$target,$context) = @_;
                     42:     return unless (ref($servers) eq 'HASH');
                     43:     my $message;
                     44:     my %lt = &Apache::lonlocal::texthash (
                     45:                  'file'     => 'File',
                     46:                  'avai'     => 'Available',
                     47:                  'yes'      => 'Yes',
                     48:                  'no'       => 'No',
                     49:                  'cn'       => 'Common Name',
                     50:                  'start'    => 'Valid From',
                     51:                  'end'      => 'Valid To',
                     52:                  'alg'      => 'Signature Algorithm',
                     53:                  'size'     => 'Public Key Size',
                     54:                  'status'   => 'Status',
                     55:                  'email'    => 'E-mail',
                     56:                  'key'      => 'Private Key',
                     57:                  'host'     => 'Connections Certificate',
                     58:                  'hostname' => 'Replication Certificate',
                     59:                  'ca'       => 'LON-CAPA CA Certificate',
                     60:     );
                     61:     my @files = qw(key host hostname ca);
                     62:     my @fields = qw(status cn start end alg size email);
                     63:     foreach my $server (sort(keys(%{$servers}))) {
                     64:         my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server,$context);
                     65:         if ($result eq 'ok' && ref($hashref) eq 'HASH') {
                     66:             if ($target eq 'web') {
1.2       raeburn    67:                 my $hostname = &Apache::lonnet::hostname($server);
1.1       raeburn    68:                 $message .= "<fieldset><legend>$hostname ($server)</legend>".
                     69:                             &Apache::loncommon::start_data_table().
                     70:                             &Apache::loncommon::start_data_table_header_row()."\n";
                     71:                 foreach my $item ('file','avai',@fields) {
                     72:                     $message .= '<th>'.$lt{$item}.'</th>';
                     73:                 }
                     74:                 $message .= &Apache::loncommon::end_data_table_header_row()."\n";
                     75:             } else {
                     76:                 $message .= $server.':';
                     77:             }
                     78:             foreach my $file (@files) {
                     79:                 if ($target eq 'web') {
                     80:                     $message .= &Apache::loncommon::start_data_table_row()."\n".
                     81:                                 '<td>'.$lt{$file}.'</td>';
                     82:                 } else {
                     83:                     $message .= $file.'=';
                     84:                 }
                     85:                 if (ref($hashref->{$file}) eq 'HASH') {
                     86:                     if ($target eq 'web') {
                     87:                         $message .= '<td>'.$lt{'yes'}.'</td>';
                     88:                     } else {
                     89:                         $message .= $lt{'yes'}.',';
                     90:                     }
                     91:                     foreach my $item (@fields) {
                     92:                         my $display = $hashref->{$file}->{$item};
                     93:                         if ($target eq 'web') {
                     94:                             if ($item eq 'status') {
                     95:                                 $display = &Apache::lonhtmlcommon::confirm_success($display);
                     96:                             }
                     97:                             $message .= "<td>$display</td>";
                     98:                         } else {
                     99:                             $message .= "$display,";
                    100:                         }
                    101:                     }
1.2       raeburn   102: 
1.1       raeburn   103:                 } else {
                    104:                     if ($target eq 'web') {
                    105:                         $message .= '<td>'.$lt{'no'}.'<td>';
                    106:                     } else {
                    107:                         $message .= $lt{'no'}.',';
                    108:                     }
                    109:                     foreach my $item (@fields) {
                    110:                         if ($target eq 'web') {
                    111:                             $message .= '<td>&nbsp;</td>';
                    112:                         } else {
                    113:                             $message .= ',';
                    114:                         }
1.2       raeburn   115:                     } 
                    116:                 }
                    117:                 if ($target eq 'web') {
                    118:                     $message .= &Apache::loncommon::end_data_table_row()."\n";
                    119:                 } else {
                    120:                     $message =~ s/,$//;
                    121:                     $message .= '&';
1.1       raeburn   122:                 }
                    123:             }
                    124:             if ($target eq 'web') {
                    125:                 $message .= &Apache::loncommon::end_data_table().'</fieldset>';
                    126:             } else {
                    127:                 $message =~ s/\&$//;
                    128:             }
                    129:             $message .= "\n";
                    130:         } else {
                    131:             if ($target eq 'web') {
1.3     ! raeburn   132:                 $message .= "$server:error\n";
1.1       raeburn   133:             } else {
1.3     ! raeburn   134:                 $message .= "$server:error\n";
1.1       raeburn   135:             }
                    136:         }
                    137:     }
                    138:     return $message;
                    139: }
                    140: 
                    141: 1;
                    142: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>