# The LearningOnline Network with CAPA
# Checksum installed LON-CAPA modules and some configuration files
#
# $Id: SSL.pm,v 1.2 2016/08/01 13:55:05 raeburn Exp $
#
# The LearningOnline Network with CAPA
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package LONCAPA::SSL;
use strict;
use lib '/home/httpd/lib/perl/';
use Apache::lonlocal();
use Apache::lonnet();
use Apache::loncommon();
use Apache::lonhtmlcommon();
use LONCAPA;
sub print_certstatus {
my ($servers,$target,$context) = @_;
return unless (ref($servers) eq 'HASH');
my $message;
my %lt = &Apache::lonlocal::texthash (
'file' => 'File',
'avai' => 'Available',
'yes' => 'Yes',
'no' => 'No',
'cn' => 'Common Name',
'start' => 'Valid From',
'end' => 'Valid To',
'alg' => 'Signature Algorithm',
'size' => 'Public Key Size',
'status' => 'Status',
'email' => 'E-mail',
'key' => 'Private Key',
'host' => 'Connections Certificate',
'hostname' => 'Replication Certificate',
'ca' => 'LON-CAPA CA Certificate',
);
my @files = qw(key host hostname ca);
my @fields = qw(status cn start end alg size email);
foreach my $server (sort(keys(%{$servers}))) {
my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server,$context);
if ($result eq 'ok' && ref($hashref) eq 'HASH') {
if ($target eq 'web') {
my $hostname = &Apache::lonnet::hostname($server);
$message .= "<fieldset><legend>$hostname ($server)</legend>".
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row()."\n";
foreach my $item ('file','avai',@fields) {
$message .= '<th>'.$lt{$item}.'</th>';
}
$message .= &Apache::loncommon::end_data_table_header_row()."\n";
} else {
$message .= $server.':';
}
foreach my $file (@files) {
if ($target eq 'web') {
$message .= &Apache::loncommon::start_data_table_row()."\n".
'<td>'.$lt{$file}.'</td>';
} else {
$message .= $file.'=';
}
if (ref($hashref->{$file}) eq 'HASH') {
if ($target eq 'web') {
$message .= '<td>'.$lt{'yes'}.'</td>';
} else {
$message .= $lt{'yes'}.',';
}
foreach my $item (@fields) {
my $display = $hashref->{$file}->{$item};
if ($target eq 'web') {
if ($item eq 'status') {
$display = &Apache::lonhtmlcommon::confirm_success($display);
}
$message .= "<td>$display</td>";
} else {
$message .= "$display,";
}
}
} else {
if ($target eq 'web') {
$message .= '<td>'.$lt{'no'}.'<td>';
} else {
$message .= $lt{'no'}.',';
}
foreach my $item (@fields) {
if ($target eq 'web') {
$message .= '<td> </td>';
} else {
$message .= ',';
}
}
}
if ($target eq 'web') {
$message .= &Apache::loncommon::end_data_table_row()."\n";
} else {
$message =~ s/,$//;
$message .= '&';
}
}
if ($target eq 'web') {
$message .= &Apache::loncommon::end_data_table().'</fieldset>';
} else {
$message =~ s/\&$//;
}
$message .= "\n";
} else {
if ($target eq 'web') {
$message .= "$server error\n";
} else {
$message .= "$server error\n";
}
}
}
return $message;
}
1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>