summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-11-07 00:56:35 +0000
committerivan <ivan>2010-11-07 00:56:35 +0000
commit2d73473ce78c22160b618e93802a9551c9c77d69 (patch)
tree8d994b6c1ee7deccdd38140f49feb1ecafbc3986 /httemplate
parent36c606eedba19978d1b5e0e1bf30d3069f28be64 (diff)
certificates ala communigate, RT#7515
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/part_svc.cgi1
-rw-r--r--httemplate/edit/process/svc_cert.cgi71
-rw-r--r--httemplate/edit/svc_cert.cgi174
-rw-r--r--httemplate/edit/svc_cert/generate_privatekey.html34
-rw-r--r--httemplate/edit/svc_cert/import_privatekey.html28
-rw-r--r--httemplate/elements/popup_link-cust_svc.html6
-rw-r--r--httemplate/view/elements/svc_Common.html10
-rw-r--r--httemplate/view/svc_Common.html4
-rw-r--r--httemplate/view/svc_cert.cgi34
9 files changed, 356 insertions, 6 deletions
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index 940ea8d25..e14acb5a9 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -15,6 +15,7 @@ Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->
Service definitions are the templates for items you offer to your customers.
<UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.)
<LI>svc_domain - Domains
+ <LI>svc_cert - Certificates
<LI>svc_forward - Mail forwarding
<LI>svc_mailinglist - Mailing list
<LI>svc_www - Virtual domain website
diff --git a/httemplate/edit/process/svc_cert.cgi b/httemplate/edit/process/svc_cert.cgi
new file mode 100644
index 000000000..1bf749f96
--- /dev/null
+++ b/httemplate/edit/process/svc_cert.cgi
@@ -0,0 +1,71 @@
+%if ( $popup ) {
+% if ( $error ) { #should redirect back to the posting page?
+<% include("/elements/header-popup.html", "Error") %>
+<P><FONT SIZE="+1" COLOR="#ff0000"><% $error |h %></FONT>
+<BR><BR>
+<P ALIGN="center">
+<BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
+</BODY></HTML>
+% } else {
+<% include('/elements/header-popup.html', $title ) %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location = '<% popurl(3). "edit/svc_cert.cgi?$svcnum" %>';
+ </SCRIPT>
+ </BODY></HTML>
+% }
+%} elsif ( $error ) {
+% $cgi->param('error', $error);
+<% $cgi->redirect(popurl(2). "svc_cert.cgi?". $cgi->query_string ) %>
+%} else {
+%#change link when we make a non-generic view
+%#<% $cgi->redirect(popurl(3). "view/svc_cert.cgi?$svcnum") %>
+<% $cgi->redirect(popurl(3). "view/svc_Common.html?svcdb=svc_cert;svcnum=$svcnum") %>
+% }
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
+my $svcnum = $1;
+
+my $new = new FS::svc_cert ( {
+ map {
+ $_, scalar($cgi->param($_));
+ } ( fields('svc_cert'), qw( pkgnum svcpart ) )
+} );
+
+my $old = '';
+if ( $svcnum ) {
+ $old = qsearchs('svc_cert', { 'svcnum' => $svcnum } ) #agent virt;
+ or die 'unknown svcnum';
+ $new->$_( $old->$_ ) for grep $old->$_, qw( privatekey );
+}
+
+my $popup = 0;
+my $title = '';
+if ( $cgi->param('privatekey') eq '_generate' ) { #generate
+ $popup = 1;
+ $title = 'Key generated';
+
+ $cgi->param('keysize') =~ /^(\d+)$/ or die 'illegal keysize';
+ my $keysize = $1;
+ $new->generate_privatekey($keysize);
+
+} elsif ( $cgi->param('privatekey') =~ /\S/ ) { #import
+ $popup = 1;
+ $title = 'Key imported';
+
+ $new->privatekey( $cgi->param('privatekey') );
+
+} #elsif ( $cgi->param('privatekey') eq '_clear' ) { #import
+
+my $error = '';
+if ($cgi->param('svcnum')) {
+ $error = $new->replace();
+} else {
+ $error = $new->insert;
+ $svcnum = $new->svcnum;
+}
+
+</%init>
diff --git a/httemplate/edit/svc_cert.cgi b/httemplate/edit/svc_cert.cgi
new file mode 100644
index 000000000..89460f3e3
--- /dev/null
+++ b/httemplate/edit/svc_cert.cgi
@@ -0,0 +1,174 @@
+<% include('/elements/header.html', "$action $svc", '') %>
+
+<% include('/elements/error.html') %>
+
+<FORM ACTION="<% $p %>edit/process/svc_cert.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+
+<% ntable("#cccccc",2) %>
+
+<TR>
+ <TD ALIGN="right">Private key</TD>
+ <TD BGCOLOR="#ffffff">
+% if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) {
+ <FONT COLOR="#33ff33">Verification OK</FONT>
+% # remove key & cert link? just unprovision?
+ </TD>
+</TR>
+
+% my $cust_main = $svc_cert->cust_svc->cust_pkg->cust_main;
+
+<TR>
+ <TD ALIGN="right">Organization</TD>
+ <TD><INPUT TYPE="text" NAME="organization" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization || $cust_main->company |h %>"></TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">Organization Unit</TD>
+ <TD><INPUT TYPE="text" NAME="organization_unit" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization_unit |h %>"></TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">City</TD>
+ <TD><% include('/elements/city.html',
+ 'city' => $svc_cert->city || $cust_main->city,
+ 'state' => $svc_cert->state || $cust_main->state,
+ 'country' => $svc_cert->country || $cust_main->country,
+ )
+ %>
+ </TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">State</TD>
+ <TD><% include('/elements/select-state.html',
+ 'city' => $svc_cert->city || $cust_main->city,
+ 'state' => $svc_cert->state || $cust_main->state,
+ 'country' => $svc_cert->country || $cust_main->country,
+ )
+ %>
+ </TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">City</TD>
+ <TD><% include('/elements/select-country.html',
+ 'city' => $svc_cert->city || $cust_main->city,
+ 'state' => $svc_cert->state || $cust_main->state,
+ 'country' => $svc_cert->country || $cust_main->country,
+ )
+ %>
+ </TD>
+</TR>
+
+% } else {
+% my $re = '';
+% if ( $svc_cert->privatekey ) {
+ <FONT COLOR="#ff0000">Verification error</FONT>
+% $re = 'Clear and Re-';
+% }
+ <% include('/elements/popup_link.html', {
+ 'action' => "svc_cert/generate_privatekey.html$link_query",
+ 'label' => $re.'Generate',
+ 'actionlabel' => 'Generate private key',
+ #opt
+ 'width' => '350',
+ 'height' => '150'
+ #'color' => '#ff0000',
+ #'closetext' => 'Go Away', # the value '' removes the link
+ })%>
+
+ or
+
+ <% include('/elements/popup_link.html', {
+ 'action' => "svc_cert/import_privatekey.html$link_query",
+ 'label' => $re.'Import',
+ 'actionlabel' => 'Import private key',
+ #opt
+ 'width' => '544',
+ 'height' => '368',
+ #'color' => '#ff0000',
+ #'closetext' => 'Go Away', # the value '' removes the link
+ })%>
+% if ( $svc_cert->privatekey ) {
+<PRE><% $svc_cert->privatekey |h %></PRE>
+% }
+ </TD>
+</TR>
+% }
+
+</TABLE>
+<BR>
+
+<INPUT TYPE="submit" VALUE="Submit">
+
+</FORM>
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+my $conf = new FS::Conf;
+
+my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_cert );
+if ( $cgi->param('error') ) {
+
+ $svc_cert = new FS::svc_cert ( {
+ map { $_, scalar($cgi->param($_)) } fields('svc_cert')
+ } );
+ $svcnum = $svc_cert->svcnum;
+ $pkgnum = $cgi->param('pkgnum');
+ $svcpart = $cgi->param('svcpart');
+ $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
+ die "No part_svc entry!" unless $part_svc;
+
+} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
+
+ $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
+ $pkgnum = $1;
+ $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
+ $svcpart = $1;
+
+ $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
+ die "No part_svc entry!" unless $part_svc;
+
+ $svc_cert = new FS::svc_cert({});
+
+ $svcnum='';
+
+ $svc_cert->set_default_and_fixed;
+
+} else { #editing
+
+ my($query) = $cgi->keywords;
+ $query =~ /^(\d+)$/ or die "unparsable svcnum";
+ $svcnum=$1;
+ $svc_cert=qsearchs('svc_cert',{'svcnum'=>$svcnum})
+ or die "Unknown (svc_cert) svcnum!";
+
+ my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
+ or die "Unknown (cust_svc) svcnum!";
+
+ $pkgnum=$cust_svc->pkgnum;
+ $svcpart=$cust_svc->svcpart;
+
+ $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
+ die "No part_svc entry!" unless $part_svc;
+
+}
+my $action = $svcnum ? 'Edit' : 'Add';
+
+my $svc = $part_svc->getfield('svc');
+
+#my $otaker = getotaker;
+
+my $p1 = popurl(1);
+
+my $link_query = "?svcnum=$svcnum;pkgnum=$pkgnum;svcpart=$svcpart";
+
+</%init>
diff --git a/httemplate/edit/svc_cert/generate_privatekey.html b/httemplate/edit/svc_cert/generate_privatekey.html
new file mode 100644
index 000000000..45414e773
--- /dev/null
+++ b/httemplate/edit/svc_cert/generate_privatekey.html
@@ -0,0 +1,34 @@
+<% include('/elements/header-popup.html', 'Generate private key' ) %>
+
+<FORM NAME="GenerateKeyForm" ACTION="<% $p %>process/svc_cert.cgi" METHOD="POST">
+
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+
+<INPUT TYPE="hidden" NAME="privatekey" VALUE="_generate">
+
+Key size: <SELECT NAME="keysize">
+ <OPTION VALUE="512">512</OPTION>
+ <OPTION VALUE="1024">1024</OPTION>
+ <OPTION VALUE="2048" SELECTED>2048</OPTION>
+ <OPTION VALUE="4096">4096</OPTION>
+</SELECT>
+
+<BR><BR>
+<INPUT TYPE="submit" VALUE="Generate">
+
+</FORM>
+</BODY>
+</HTML>
+<%init>
+
+$cgi->param('svcnum') =~ /^(\d*)$/ or die 'illegal svcnum';
+my $svcnum = $1;
+$cgi->param('pkgnum') =~ /^(\d*)$/ or die 'illegal pkgnum';
+my $pkgnum = $1;
+$cgi->param('svcpart') =~ /^(\d*)$/ or die 'illegal svcpart';
+my $svcpart = $1;
+
+</%init>
+
diff --git a/httemplate/edit/svc_cert/import_privatekey.html b/httemplate/edit/svc_cert/import_privatekey.html
new file mode 100644
index 000000000..52e6002f8
--- /dev/null
+++ b/httemplate/edit/svc_cert/import_privatekey.html
@@ -0,0 +1,28 @@
+<% include('/elements/header-popup.html', 'Import private key' ) %>
+
+<% include('/elements/error.html') %>
+
+<FORM NAME="ImportKeyForm" ACTION="<% $p %>process/svc_cert.cgi" METHOD="POST">
+
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+
+<TEXTAREA NAME="privatekey" COLS=64 ROWS=15 STYLE="font-family:monospace"></TEXTAREA>
+
+<BR><BR>
+<INPUT TYPE="submit" VALUE="Import">
+
+</FORM>
+</BODY>
+</HTML>
+<%init>
+
+$cgi->param('svcnum') =~ /^(\d*)$/ or die 'illegal svcnum';
+my $svcnum = $1;
+$cgi->param('pkgnum') =~ /^(\d*)$/ or die 'illegal pkgnum';
+my $pkgnum = $1;
+$cgi->param('svcpart') =~ /^(\d*)$/ or die 'illegal svcpart';
+my $svcpart = $1;
+
+</%init>
diff --git a/httemplate/elements/popup_link-cust_svc.html b/httemplate/elements/popup_link-cust_svc.html
index 8255ffc04..39c0d3181 100644
--- a/httemplate/elements/popup_link-cust_svc.html
+++ b/httemplate/elements/popup_link-cust_svc.html
@@ -4,16 +4,16 @@ Example:
include('/elements/init_overlib.html')
- include( '/elements/svc_popup_link.html', { #hashref or a list, either way
+ include('/elements/popup_link-cust_svc.html', { #hashref or a list, either way
#required
'action' => 'content.html', # uri for content of popup which should
# be suitable for appending '?svcnum='
'label' => 'click me', # text of <A> tag
- 'cust_svc' => $cust_svc # a FS::cust_svc object
+ 'cust_svc' => $cust_svc # a FS::cust_svc object or FS::svc_* object
#strongly recommended (you want a title, right?)
- 'actionlabel => 'You clicked', # popup title
+ 'actionlabel' => 'You clicked', # popup title
#opt
'width' => '540',
diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html
index 8a352f3fa..618d33eed 100644
--- a/httemplate/view/elements/svc_Common.html
+++ b/httemplate/view/elements/svc_Common.html
@@ -18,6 +18,10 @@
# defaults to "edit/$table.cgi?", will have svcnum appended
'edit_url' =>
+
+ #at the very bottom (well, as low as you can go from here)
+ 'html_foot' => '',
+
)
</%doc>
@@ -56,12 +60,14 @@ Unprovision this Service</A>
% foreach my $f ( @$fields ) {
%
-% my($field, $type);
+% my($field, $type, $value);
% if ( ref($f) ) {
% $field = $f->{'field'},
+% $value = $f->{'value'} ? &{ $f->{'value'} }($svc_x) : $svc_x->$field;
% $type = $f->{'type'} || 'text',
% } else {
% $field = $f;
+% $value = $svc_x->$field;
% $type = 'text';
% }
%
@@ -78,7 +84,7 @@ Unprovision this Service</A>
% #eventually more options for <SELECT>, etc. fields
- <TD BGCOLOR="#ffffff"><% $svc_x->$field %><TD>
+ <TD BGCOLOR="#ffffff"><% $value %><TD>
</TR>
diff --git a/httemplate/view/svc_Common.html b/httemplate/view/svc_Common.html
index defbee974..7ed63c7aa 100644
--- a/httemplate/view/svc_Common.html
+++ b/httemplate/view/svc_Common.html
@@ -1,6 +1,6 @@
<% include('elements/svc_Common.html',
'table' => $table,
- 'edit_url' => $p."edit/svc_Common.html?svcdb=$table;svcnum=",
+ 'edit_url' => $edit_url, #$p."edit/svc_Common.html?svcdb=$table;svcnum=",
%opt,
)
%>
@@ -12,6 +12,8 @@ $cgi->param('svcdb') =~ /^(svc_\w+)$/ or die "unparsable svcdb";
my $table = $1;
require "FS/$table.pm";
+my $edit_url = svc_url( 'm' => $m, 'action' => 'edit', 'svcdb' => $table, query => '' );
+
my %opt;
if ( UNIVERSAL::can("FS::$table", 'table_info') ) {
$opt{'name'} = "FS::$table"->table_info->{'name'};
diff --git a/httemplate/view/svc_cert.cgi b/httemplate/view/svc_cert.cgi
new file mode 100644
index 000000000..92902d6d2
--- /dev/null
+++ b/httemplate/view/svc_cert.cgi
@@ -0,0 +1,34 @@
+<% include('elements/svc_Common.html',
+ 'table' => 'svc_cert',
+ 'labels' => \%labels,
+ #'html_foot' => $html_foot,
+ 'fields' => \@fields,
+ )
+%>
+<%init>
+
+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 ) {
+ '<FONT COLOR="#33ff33">Verification OK</FONT>';
+ } elsif ( $svc_cert->privatekey ) {
+ '<FONT COLOR="#ff0000">Verification error</FONT>';
+ } else {
+ '<I>(none)</I>';
+ }
+ },
+ },
+ qw( organization organization_unit city state country cert_contact )
+);
+
+</%init>