X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fsvc_cert.cgi;h=0cd66b422618eed106314b684ac7fee67891c644;hb=afc02cadca8e8033285bb213bcde620cb8fa4f99;hp=eeda9a1dd0827e10771968323bb7d68028417170;hpb=2d77bbdb0f3deff86a4b721e7b4f8be7ff5996d4;p=freeside.git
diff --git a/httemplate/view/svc_cert.cgi b/httemplate/view/svc_cert.cgi
index eeda9a1dd..0cd66b422 100644
--- a/httemplate/view/svc_cert.cgi
+++ b/httemplate/view/svc_cert.cgi
@@ -1,19 +1,205 @@
<% 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 ) {
+
+ my $out = '';
+
+ my %hash = $svc_cert->check_csr;
+
+ $out .= include('/elements/table-grid.html'). #'
'.
+ ''.
+ 'Requested by |
';
+
+ my $col = $svc_cert->subj_col;
+
+ foreach my $key (keys %hash) {
+ $out .= "". $labels{$col->{$key}}. " | ".
+ "". $hash{$key}. " |
";
+ }
+
+ $out .= '
';
+
+ $out .=
+ ''. $svc_cert->csr.
+ '
';
+
+ $out;
+
+ } 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;
+
+ tie my %w, 'Tie::IxHash',
+ 'subject' => 'Issued to',
+ 'issuer' => 'Issued by',
+ ;
+
+ my $out = '';
+
+ foreach my $w ( keys %w ) {
+
+ $out .= include('/elements/table-grid.html'). #''.
+ ''.
+ $w{$w}. ' | ';
+
+ my $col = $svc_cert->subj_col;
+
+ my $subj = $hash{$w};
+ foreach my $key (keys %$col) { #( keys %$subj ) {
+ $out .= "". $labels{$col->{$key}}. " | ".
+ "". $subj->{$key}. " | ";
+ }
+
+ $out .= ' | ';
+ }
+ $out .= ' |
';
+
+ $out .= ''.
+ 'Serial number | '.
+ "$hash{serial} |
".
+ 'Valid | '.
+ "$hash{notBefore} - $hash{notAfter} |
".
+ '
';
+
+ my $svcnum = $svc_cert->svcnum;
+
+ if ( $hash{'selfsigned'} ) {
+ $out .= qq(
Re-generate self-signed).
+ ' '.
+ include('/elements/popup_link.html', {
+ 'action' => $p."edit/svc_cert/import_certificate.html".
+ "?svcnum=$svcnum",
+ 'label' => 'Import issued certificate', #link
+ 'actionlabel' => 'Import issued certificate', #title
+ #opt
+ 'width' => '544',
+ 'height' => '368',
+ #'color' => '#ff0000',
+ }).
+ '
';
+ }
+
+ $out .= ''.
+ $svc_cert->certificate.
+ '';
+
+ $out;
+ } elsif ( $svc_cert->csr ) {
+ my $svcnum = $svc_cert->svcnum;
+ qq(Generate self-signed);
+ } else {
+ '';
+ }
+ },
+ },
+ { 'field'=>'cacert',
+ 'value'=> sub {
+ my $svc_cert = shift;
+ if ( $svc_cert->cacert ) {
+
+ my %hash = $svc_cert->check_cacert;
+
+ tie my %w, 'Tie::IxHash',
+ 'subject' => 'Issued to',
+ 'issuer' => 'Issued by',
+ ;
+
+ my $out = '
';
+
+ foreach my $w ( keys %w ) {
+
+ $out .= include('/elements/table-grid.html'). #''.
+ ''.
+ $w{$w}. ' | ';
+
+ my $col = $svc_cert->subj_col;
+
+ my $subj = $hash{$w};
+ foreach my $key (keys %$col) { #( keys %$subj ) {
+ $out .= "". $labels{$col->{$key}}. " | ".
+ "". $subj->{$key}. " | ";
+ }
+
+ $out .= ' | ';
+ }
+ $out .= ' |
';
+
+ $out .= ''.
+ 'Serial number | '.
+ "$hash{serial} |
".
+ 'Valid | '.
+ "$hash{notBefore} - $hash{notAfter} |
".
+ '
';
+
+ $out .= ''.
+ $svc_cert->certificate.
+ '';
+
+ $out;
+
+ } else {
+
+ my $svcnum = $svc_cert->svcnum;
+
+ include('/elements/popup_link.html', {
+ 'action' => $p."edit/svc_cert/import_cacert.html".
+ "?svcnum=$svcnum",
+ 'label' => 'Import certificate authority chain',#link
+ 'actionlabel' => 'Import certificate authority chain',#title
+ #opt
+ 'width' => '544',
+ 'height' => '368',
+ #'color' => '#ff0000',
+ }). ' (optional)'.
+ '
';
+
+ }
+ },
+ },
+);
%init>