From 729ceea3edac7b5364aa572c894991a979a53f2b Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Nov 2010 05:30:29 +0000 Subject: certificates ala communigate, RT#7515 --- httemplate/view/svc_cert.cgi | 76 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 11 deletions(-) (limited to 'httemplate/view/svc_cert.cgi') diff --git a/httemplate/view/svc_cert.cgi b/httemplate/view/svc_cert.cgi index eeda9a1dd..36f598b9a 100644 --- a/httemplate/view/svc_cert.cgi +++ b/httemplate/view/svc_cert.cgi @@ -1,19 +1,73 @@ <% include('elements/svc_Common.html', - 'table' => 'svc_pbx', - 'edit_url' => $p."edit/svc_Common.html?svcdb=svc_pbx;svcnum=", - #'labels' => \%labels, + 'table' => 'svc_cert', + 'labels' => \%labels, #'html_foot' => $html_foot, - 'fields' => [] + 'fields' => \@fields, ) %> <%init> -#my $fields = FS::svc_pbx->table_info->{'fields'}; -#my %labels = map { $_ => ( ref($fields->{$_}) -# ? $fields->{$_}{'label'} -# : $fields->{$_} -# ); -# } -# keys %$fields; +my $fields = FS::svc_cert->table_info->{'fields'}; +my %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } + keys %$fields; + +my @fields = ( + { field=>'privatekey', + value=> sub { + my $svc_cert = shift; + if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) { + 'Verification OK'; + } elsif ( $svc_cert->privatekey ) { + 'Verification error'; + } else { + '(none)'; + } + }, + }, + qw( common_name organization organization_unit city state country cert_contact + ), + { 'field'=>'csr', + 'value'=> sub { + my $svc_cert = shift; + if ( $svc_cert->csr ) { #display the subject etc? + '
'. $svc_cert->csr.
+        '
'; + } elsif ( $svc_cert->common_name ) { + my $svcnum = $svc_cert->svcnum; + qq(Generate); + } else { + ''; + } + }, + }, + { 'field'=>'certificate', + 'value'=> sub { + my $svc_cert = shift; + if ( $svc_cert->certificate ) { + + my %hash = $svc_cert->check_certificate; + my $out = ''; #XXX better formatting + foreach my $key ( keys %hash ) { + $out .= ""; + } + $out .= '
$key$hash{$key}
'; + + $out .= '
'.
+                $svc_cert->certificate.
+                '
'; + $out; + } elsif ( $svc_cert->csr ) { + my $svcnum = $svc_cert->svcnum; + qq(Generate self-signed); + } else { + ''; + } + }, + }, +); -- cgit v1.2.1