summaryrefslogtreecommitdiffstats
path: root/pki/base/ra/forms
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/ra/forms')
-rwxr-xr-xpki/base/ra/forms/admin/group/add.cgi86
-rwxr-xr-xpki/base/ra/forms/admin/group/add_member.cgi80
-rwxr-xr-xpki/base/ra/forms/admin/group/add_new.cgi86
-rwxr-xr-xpki/base/ra/forms/admin/group/delete.cgi79
-rwxr-xr-xpki/base/ra/forms/admin/group/delete_member.cgi79
-rwxr-xr-xpki/base/ra/forms/admin/group/index.cgi115
-rwxr-xr-xpki/base/ra/forms/admin/group/read.cgi125
-rwxr-xr-xpki/base/ra/forms/admin/index.cgi80
-rwxr-xr-xpki/base/ra/forms/admin/user/add.cgi99
-rwxr-xr-xpki/base/ra/forms/admin/user/add_new.cgi87
-rwxr-xr-xpki/base/ra/forms/admin/user/delete.cgi79
-rwxr-xr-xpki/base/ra/forms/admin/user/index.cgi118
-rwxr-xr-xpki/base/ra/forms/admin/user/read.cgi97
-rwxr-xr-xpki/base/ra/forms/agent/cert/index.cgi119
-rwxr-xr-xpki/base/ra/forms/agent/cert/read.cgi104
-rwxr-xr-xpki/base/ra/forms/agent/cert/revoke.cgi89
-rwxr-xr-xpki/base/ra/forms/agent/cert/submit.cgi104
-rwxr-xr-xpki/base/ra/forms/agent/error.cgi81
-rwxr-xr-xpki/base/ra/forms/agent/index.cgi83
-rwxr-xr-xpki/base/ra/forms/agent/request/add_note.cgi93
-rwxr-xr-xpki/base/ra/forms/agent/request/index.cgi146
-rwxr-xr-xpki/base/ra/forms/agent/request/op.cgi153
-rwxr-xr-xpki/base/ra/forms/agent/request/read.cgi119
-rwxr-xr-xpki/base/ra/forms/ee/agent/enroll.cgi127
-rwxr-xr-xpki/base/ra/forms/ee/agent/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/agent/new.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/agent/start.cgi69
-rwxr-xr-xpki/base/ra/forms/ee/agent/submit.cgi88
-rwxr-xr-xpki/base/ra/forms/ee/error.cgi81
-rwxr-xr-xpki/base/ra/forms/ee/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/request/getcert.cgi93
-rwxr-xr-xpki/base/ra/forms/ee/request/importcert.cgi82
-rwxr-xr-xpki/base/ra/forms/ee/request/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/request/status.cgi94
-rwxr-xr-xpki/base/ra/forms/ee/scep/enroll.cgi112
-rwxr-xr-xpki/base/ra/forms/ee/scep/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/scep/installer.cgi74
-rwxr-xr-xpki/base/ra/forms/ee/scep/manager.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/scep/pkiclient.cgi113
-rwxr-xr-xpki/base/ra/forms/ee/scep/submit.cgi91
-rwxr-xr-xpki/base/ra/forms/ee/server/admin.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/server/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/server/submit.cgi93
-rwxr-xr-xpki/base/ra/forms/ee/user/index.cgi68
-rwxr-xr-xpki/base/ra/forms/ee/user/renew.cgi165
-rwxr-xr-xpki/base/ra/forms/ee/user/renewal.cgi74
-rwxr-xr-xpki/base/ra/forms/ee/user/submit.cgi112
-rwxr-xr-xpki/base/ra/forms/ee/user/user.cgi68
-rwxr-xr-xpki/base/ra/forms/index.cgi76
49 files changed, 4525 insertions, 0 deletions
diff --git a/pki/base/ra/forms/admin/group/add.cgi b/pki/base/ra/forms/admin/group/add.cgi
new file mode 100755
index 000000000..212330d0d
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/add.cgi
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $gid = $util->get_val($q->param('gid'));
+ my $name = $util->get_val($q->param('name'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my $ref = $store->read_group($gid);
+ if (defined($ref)) {
+ # gid used
+ print $q->redirect("/admin/group/add_new.cgi?error=exist");
+ return;
+ }
+ my $ref = $store->add_group($gid, $name);
+ $store->close();
+
+ print $q->redirect("/admin/group/index.cgi");
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/add_member.cgi b/pki/base/ra/forms/admin/group/add_member.cgi
new file mode 100755
index 000000000..d60fe965e
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/add_member.cgi
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $gid = $util->get_val($q->param('gid'));
+ my $userid = $util->get_val($q->param('uid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ $store->add_user_to_group($gid, $userid);
+ $store->close();
+
+ print $q->redirect("/admin/group/read.cgi?gid=" . $gid);
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/add_new.cgi b/pki/base/ra/forms/admin/group/add_new.cgi
new file mode 100755
index 000000000..5a1ca7eda
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/add_new.cgi
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+ my $error = $q->param('error');
+ $context{error} = $util->html_encode($error);
+
+ my $result = $parser->execute_file_with_context("admin/group/add_new.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/delete.cgi b/pki/base/ra/forms/admin/group/delete.cgi
new file mode 100755
index 000000000..5fb1f22ce
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/delete.cgi
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $gid = $util->get_val($q->param('gid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ $store->delete_group($gid);
+ $store->close();
+
+ print $q->redirect("/admin/group/index.cgi");
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/delete_member.cgi b/pki/base/ra/forms/admin/group/delete_member.cgi
new file mode 100755
index 000000000..2e516eeee
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/delete_member.cgi
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $gid = $util->get_val($q->param('gid'));
+ my $userid = $util->get_val($q->param('uid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ $store->delete_user_from_group($gid, $userid);
+ $store->close();
+
+ print $q->redirect("/admin/group/read.cgi?gid=" . $gid);
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/index.cgi b/pki/base/ra/forms/admin/group/index.cgi
new file mode 100755
index 000000000..07dc653e6
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/index.cgi
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+
+ my $util = PKI::Base::Util->new();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $sp = $util->get_alphanum_val($q->param('sp'));
+ if ($sp eq "") {
+ $sp = "0";
+ }
+ $context{sp} = $sp;
+ my $mc = $util->get_alphanum_val($q->param('mc'));
+ if ($mc eq "") {
+ $mc = "20";
+ }
+ $context{mc} = $mc;
+ $context{pp} = $sp - $mc; # previous pos (for paging)
+ $context{np} = $sp + $mc; # next pos (for paging)
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my @groups = $store->list_groups($sp, $mc);
+ $store->close();
+
+ my @r;
+ my $i = 0;
+ foreach my $group (@groups) {
+ $r[$i] = new PKI::RA::GlobalVar(
+ getGID => sub { return $util->html_encode(Encode::decode('UTF-8', $group->{'gid'})) },
+ getName => sub { return $util->html_encode(Encode::decode('UTF-8', $group->{'name'})) },
+ );
+ $i++;
+ }
+ $context{rows} = \@r;
+
+ my $result = $parser->execute_file_with_context("admin/group/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/group/read.cgi b/pki/base/ra/forms/admin/group/read.cgi
new file mode 100755
index 000000000..9ede3aa53
--- /dev/null
+++ b/pki/base/ra/forms/admin/group/read.cgi
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $gid = $util->get_val($q->param('gid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my $ref = $store->read_group($gid);
+
+ $context{gid} = $util->html_encode(Encode::decode('UTF-8', $ref->{'gid'}));
+ $context{name} = $util->html_encode(Encode::decode('UTF-8', $ref->{'name'}));
+
+ my @members = $store->list_all_members($gid);
+ my @users = $store->list_all_non_members($gid);
+ $store->close();
+
+ # new member in the group
+ my @r;
+ my $i = 0;
+ foreach my $member (@members) {
+ $r[$i] = new PKI::RA::GlobalVar(
+ getUID => sub { return $util->html_encode($member->{'uid'}) },
+ );
+ $i++;
+ }
+ $context{members} = \@r;
+
+ # read users
+ my @u;
+ $i = 0;
+ foreach my $user (@users) {
+ $u[$i] = new PKI::RA::GlobalVar(
+ getUID => sub { return $util->html_encode($user->{'uid'}) },
+ );
+ $i++;
+ }
+ if ($i == 0) {
+ $context{non_member_exists} = 0;
+ } else {
+ $context{non_member_exists} = 1;
+ }
+ $context{users} = \@u;
+
+ my $result = $parser->execute_file_with_context("admin/group/read.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/index.cgi b/pki/base/ra/forms/admin/index.cgi
new file mode 100755
index 000000000..2db7b2500
--- /dev/null
+++ b/pki/base/ra/forms/admin/index.cgi
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::UserStore;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi?error=Authentication%20Error");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $result = $parser->execute_file_with_context("admin/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/user/add.cgi b/pki/base/ra/forms/admin/user/add.cgi
new file mode 100755
index 000000000..94c4bae81
--- /dev/null
+++ b/pki/base/ra/forms/admin/user/add.cgi
@@ -0,0 +1,99 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $userid = $util->get_val($q->param('uid'));
+ my $name = $util->get_val($q->param('name'));
+ my $email = $util->get_val($q->param('email'));
+ my $certificate = $util->get_val($q->param('certificate'));
+
+ if ($certificate =~ /BEGIN CERTIFICATE/ ||
+ $certificate =~ /END CERTIFICATE/) {
+ # do nothing
+ } else {
+ print $q->redirect("/admin/user/add_new.cgi?error=cert_header");
+ return;
+ }
+ $certificate =~ s/-----BEGIN CERTIFICATE-----//g;
+ $certificate =~ s/-----END CERTIFICATE-----//g;
+ $certificate =~ s/[\r\n]//g;
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my $ref = $store->read_user($userid);
+ if (defined($ref)) {
+ # uid used
+ print $q->redirect("/admin/user/add_new.cgi?error=exist");
+ return;
+ }
+ my $ref = $store->add_user($userid, $name, $email, $certificate);
+ $store->close();
+
+ print $q->redirect("/admin/user/index.cgi");
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/user/add_new.cgi b/pki/base/ra/forms/admin/user/add_new.cgi
new file mode 100755
index 000000000..8bfbd0e9e
--- /dev/null
+++ b/pki/base/ra/forms/admin/user/add_new.cgi
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $error = $util->get_val($q->param('error'));
+ $context{error} = $error;
+
+ my $result = $parser->execute_file_with_context("admin/user/add_new.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/user/delete.cgi b/pki/base/ra/forms/admin/user/delete.cgi
new file mode 100755
index 000000000..707035edb
--- /dev/null
+++ b/pki/base/ra/forms/admin/user/delete.cgi
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my $util = PKI::Base::Util->new();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $userid = $util->get_val($q->param('uid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ $store->delete_user($userid);
+ $store->close();
+
+ print $q->redirect("/admin/user/index.cgi");
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/user/index.cgi b/pki/base/ra/forms/admin/user/index.cgi
new file mode 100755
index 000000000..c845ae1dc
--- /dev/null
+++ b/pki/base/ra/forms/admin/user/index.cgi
@@ -0,0 +1,118 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use PKI::Base::Registry;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my $util = PKI::Base::Util->new();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $status = $util->get_alphanum_val($q->param('status'));
+ $context{status} = $status;
+
+ my $sp = $util->get_alphanum_val($q->param('sp'));
+ if ($sp eq "") {
+ $sp = "0";
+ }
+ $context{sp} = $sp;
+ my $mc = $util->get_alphanum_val($q->param('mc'));
+ if ($mc eq "") {
+ $mc = "20";
+ }
+ $context{mc} = $mc;
+ $context{pp} = $sp - $mc; # previous pos (for paging)
+ $context{np} = $sp + $mc; # next pos (for paging)
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my @users = $store->list_users($sp, $mc);
+ $store->close();
+
+ my @r;
+ my $i = 0;
+ foreach my $user (@users) {
+ $r[$i] = new PKI::RA::GlobalVar(
+ getUID => sub { return $util->html_encode($user->{'uid'}) },
+ getName => sub { return $util->html_encode(Encode::decode('UTF-8',$user->{'name'})) },
+ getEmail => sub { return $util->html_encode($user->{'email'}) },
+ );
+ $i++;
+ }
+ $context{rows} = \@r;
+
+ my $result = $parser->execute_file_with_context("admin/user/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/admin/user/read.cgi b/pki/base/ra/forms/admin/user/read.cgi
new file mode 100755
index 000000000..08d2fd3f7
--- /dev/null
+++ b/pki/base/ra/forms/admin/user/read.cgi
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->admin_auth($cfg)) {
+ print $q->redirect("/admin/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $uid;
+
+ my $userid = $util->get_val($q->param('uid'));
+
+ my $store = PKI::Base::UserStore->new();
+ $store->open($cfg);
+ my $ref = $store->read_user($userid);
+ $store->close();
+
+ $context{userid} = $util->html_encode($ref->{'uid'});
+ $context{name} = $util->html_encode(Encode::decode('UTF-8', $ref->{'name'}));
+ $context{email} = $util->html_encode($ref->{'email'});
+ $context{certificate} = $util->breakline($util->html_encode($ref->{'certificate'}),40);
+
+ my $result = $parser->execute_file_with_context("admin/user/read.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/cert/index.cgi b/pki/base/ra/forms/agent/cert/index.cgi
new file mode 100755
index 000000000..46e5b8c2c
--- /dev/null
+++ b/pki/base/ra/forms/agent/cert/index.cgi
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Base::CertStore;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my @roles = $self->get_current_roles($cfg);
+ my $r = join(",",@roles);
+
+ my $sp = $util->get_alphanum_val($q->param('sp'));
+ if ($sp eq "") {
+ $sp = "0";
+ }
+ $context{sp} = $sp;
+ my $mc = $util->get_alphanum_val($q->param('mc'));
+ if ($mc eq "") {
+ $mc = "20";
+ }
+ $context{mc} = $mc;
+ $context{pp} = $sp - $mc; # previous pos (for paging)
+ $context{np} = $sp + $mc; # next pos (for paging)
+
+ my $cs = PKI::Base::CertStore->new();
+ $cs->open($cfg);
+ my @certs = $cs->list_certs_by_approver($uid, $sp, $mc);
+ $cs->close();
+
+ my @r;
+ my $i = 0;
+ foreach my $cert (@certs) {
+ $r[$i] = new PKI::RA::GlobalVar(
+ getReqId => sub { return $util->html_encode($cert->{'rid'}) },
+ getSerialno => sub { return $util->html_encode($cert->{'serialno'}) },
+ getSubjectDN => sub { return $util->html_encode($cert->{'subject_dn'}) },
+ getCertificate => sub { return $util->html_encode($cert->{'certificate'}) },
+ getApprovedBy => sub { return $util->html_encode($cert->{'approved_by'}) },
+ getCreatedAt => sub { return $util->html_encode($cert->{'created_at'}); },
+ );
+ $i++;
+ }
+ $context{rows} = \@r;
+
+ my $result = $parser->execute_file_with_context("agent/cert/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/cert/read.cgi b/pki/base/ra/forms/agent/cert/read.cgi
new file mode 100755
index 000000000..f434baedb
--- /dev/null
+++ b/pki/base/ra/forms/agent/cert/read.cgi
@@ -0,0 +1,104 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Conn::CA;
+use Encode;
+use vars qw (@ISA);
+use PKI::Service::Op;
+
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $serialno = $util->get_alphanum_val($q->param('serialno'));
+
+ my $cs = PKI::Base::CertStore->new();
+ $cs->open($cfg);
+ my $ref = $cs->read_certificate_by_approver($uid, $serialno);
+ $cs->close();
+
+ my $ca = PKI::Conn::CA->new();
+ $ca->open($cfg);
+ my $certStatus = $ca->getCertStatus("ca1", $serialno);
+ $ca->close();
+
+
+ $context{certificate} = $util->breakline($util->html_encode($ref->{'certificate'}), 40);
+
+ $context{serialno} = $util->html_encode($ref->{'serialno'});
+ $context{subject_dn} = $util->html_encode(Encode::decode('UTF-8', $ref->{'subject_dn'}));
+ $context{created_at} = $util->html_encode($ref->{'created_at'});
+ $context{approved_by} = $util->html_encode($ref->{'approved_by'});
+ $context{rid} = $util->html_encode($ref->{'rid'});
+ $context{certStatus} = $util->html_encode($certStatus);
+
+ my $result = $parser->execute_file_with_context("agent/cert/read.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/cert/revoke.cgi b/pki/base/ra/forms/agent/cert/revoke.cgi
new file mode 100755
index 000000000..1e483aea0
--- /dev/null
+++ b/pki/base/ra/forms/agent/cert/revoke.cgi
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+use PKI::Base::Util;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $serialno = $util->get_alphanum_val($q->param('serialno'));
+ my $subject_dn = $util->get_val($q->param('subject_dn'));
+ my $rid = $util->get_alphanum_val($q->param('rid'));
+
+ $context{serialno} = $util->html_encode($serialno);
+ $context{subject_dn} = $util->html_encode(Encode::decode('UTF-8',$subject_dn));
+ $context{rid} = $util->html_encode($rid);
+
+ my $result = $parser->execute_file_with_context("agent/cert/revoke.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/cert/submit.cgi b/pki/base/ra/forms/agent/cert/submit.cgi
new file mode 100755
index 000000000..571385f3a
--- /dev/null
+++ b/pki/base/ra/forms/agent/cert/submit.cgi
@@ -0,0 +1,104 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Conn::CA;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $serialno = $util->get_alphanum_val($q->param('serialno'));
+ my $subject_dn = $util->get_val($q->param('subject_dn'));
+ my $reason = $util->get_alphanum_val($q->param('reason'));
+ my $rid = $util->get_alphanum_val($q->param('rid'));
+
+ my $ca = PKI::Conn::CA->new();
+ $ca->open($cfg);
+ $ca->revoke($rid, "ca1", $serialno, $reason);
+ $ca->close();
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+
+ my $ref = $queue->read_request($rid);
+ $context{errorString} = $util->html_encode($ref->{'errorString'});
+ $queue->close();
+
+ $context{rid} = $util->html_encode($rid);
+ $context{serialno} = $util->html_encode($serialno);
+ $context{subject_dn} = $util->html_encode(Encode::decode('UTF-8', $subject_dn));
+
+ my $result = $parser->execute_file_with_context("agent/cert/submit.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/error.cgi b/pki/base/ra/forms/agent/error.cgi
new file mode 100755
index 000000000..fa13365a7
--- /dev/null
+++ b/pki/base/ra/forms/agent/error.cgi
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::UserStore;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $util = PKI::Base::Util->new();
+
+ my $error = $util->get_val($q->param('error'));
+
+ my %context;
+ if ($error ne "") {
+ $context{has_error} = 1;
+ $context{'error'} = $util->html_encode($error);
+ }
+
+ my $result = $parser->execute_file_with_context("agent/error.vm", \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/index.cgi b/pki/base/ra/forms/agent/index.cgi
new file mode 100755
index 000000000..c8f2040fe
--- /dev/null
+++ b/pki/base/ra/forms/agent/index.cgi
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::UserStore;
+use PKI::Base::Registry;
+use PKI::Base::Util;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi?error=Authentication%20Error");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $result = $parser->execute_file_with_context("agent/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/request/add_note.cgi b/pki/base/ra/forms/agent/request/add_note.cgi
new file mode 100755
index 000000000..0ffac91c7
--- /dev/null
+++ b/pki/base/ra/forms/agent/request/add_note.cgi
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use PKI::Base::TimeTool;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $id = $util->get_alphanum_val($q->param('id'));
+ my $note = $util->get_val($q->param('note'));
+
+ if ($note eq "") {
+ # dont add anything
+ print $q->redirect("/agent/request/read.cgi?id=" . $id);
+ return;
+ }
+
+ my $timet = PKI::Base::TimeTool->new();
+ my $now = $timet->get_time();
+ my $new_note = "==== Note created by $uid at $now ====\n" .
+ $note . "\n";
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $ref = $queue->read_request($id);
+ $queue->set_request($id, "note", $ref->{'note'} . $new_note);
+ $queue->close();
+
+ print $q->redirect("/agent/request/read.cgi?id=" . $id);
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/request/index.cgi b/pki/base/ra/forms/agent/request/index.cgi
new file mode 100755
index 000000000..81b25977a
--- /dev/null
+++ b/pki/base/ra/forms/agent/request/index.cgi
@@ -0,0 +1,146 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::RA::GlobalVar;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use PKI::Service::Op;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+ $self->debug_log( $cfg, "in request/index.cgi, uid == $uid");
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my @roles = $self->get_current_roles($cfg);
+# my $r = join(",",@roles);
+
+ my $status = $util->get_alphanum_val($q->param('status'));
+ if ($status eq "") {
+ $context{status} = "";
+ } else {
+ $context{status} = $util->html_encode($status);
+ }
+
+ my $sp = $util->get_alphanum_val($q->param('sp'));
+ if ($sp eq "") {
+ $sp = "0";
+ }
+ $context{sp} = $sp;
+ my $mc = $util->get_alphanum_val($q->param('mc'));
+ if ($mc eq "") {
+ $mc = "20";
+ }
+ $context{mc} = $mc;
+ $context{pp} = $sp - $mc; # previous pos (for paging)
+ $context{np} = $sp + $mc; # next pos (for paging)
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $total = $queue->count_requests_by_roles(\@roles, $status);
+ $context{total} = $util->html_encode($total);
+
+ my @reqs = $queue->list_requests_by_roles(\@roles, $status, $sp, $mc);
+# my @reqs = $queue->list_requests_by_roles($r, $status, $sp, $mc);
+ $queue->close();
+
+ my @r;
+ my $i = 0;
+ foreach my $req (@reqs) {
+ $r[$i] = new PKI::RA::GlobalVar(
+ getId => sub { return $util->html_encode($req->{'rowid'}) },
+ getType => sub { return $util->html_encode($req->{'type'}) },
+ getStatus => sub { return $util->html_encode($req->{'status'}) },
+ getError => sub { return $util->html_encode($req->{'errorString'}) },
+ getAssignedTo => sub { return $util->html_encode($req->{'assigned_to'}) },
+ getData => sub { return $util->html_encode($req->{'data'}); },
+ getCreatedBy => sub { return $util->html_encode($req->{'created_by'}); },
+ getCreatedAt => sub { return $util->html_encode($req->{'created_at'}); },
+ );
+ $i++;
+ }
+ $context{rows} = \@r;
+
+ if ($sp - $mc < 0) {
+ $context{show_previous} = "no";
+ } else {
+ $context{show_previous} = "yes";
+ }
+
+ if ($i < 20) {
+ $context{show_next} = "no";
+ } else {
+ $context{show_next} = "yes";
+ }
+
+ my $result = $parser->execute_file_with_context("agent/request/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/request/op.cgi b/pki/base/ra/forms/agent/request/op.cgi
new file mode 100755
index 000000000..363d7121b
--- /dev/null
+++ b/pki/base/ra/forms/agent/request/op.cgi
@@ -0,0 +1,153 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use Benchmark;
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use PKI::Base::Util;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $st = new Benchmark;
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+ my $type = $util->get_alphanum_val($q->param('type'));
+ my $id = $util->get_alphanum_val($q->param('id'));
+
+ my $db_st = new Benchmark;
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+
+ my $ref;
+
+ my @roles = $self->get_current_roles($cfg);
+ my $pref = $queue->read_request_by_roles(\@roles, $id);
+
+ if (! defined $pref) {
+ $queue->close();
+ $self->debug_log($cfg, "Invalid attempt to process request id= " . $id .
+ " by userid= " . $uid);
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+
+ my $curr_status = $pref->{'status'};
+ if ($type eq "approve") {
+ if (($curr_status ne "OPEN") && ($curr_status ne "ERROR")) {
+ $queue->close();
+ print $q->redirect("/agent/request/read.cgi?id=$id");
+ return;
+ }
+
+ $ref = $queue->approve_request($id, $uid);
+ } elsif ($type eq "reject") {
+ if (($curr_status ne "OPEN") && ($curr_status ne "ERROR")) {
+ $queue->close();
+ print $q->redirect("/agent/request/read.cgi?id=$id");
+ return;
+ }
+
+ $ref = $queue->reject_request($id, $uid);
+ }
+ $queue->close();
+ my $db_et = new Benchmark;
+
+ $context{data} = $util->breakline($util->html_encode(Encode::decode('UTF-8', $ref->{'data'})), 40);
+ $context{output} = $util->breakline($util->html_encode($ref->{'output'}), 40);
+ $context{serialno} = $util->html_encode($ref->{'serialno'});
+ $context{type} = $util->html_encode($ref->{'type'});
+ $context{ip} = $util->html_encode($ref->{'ip'});
+ $context{note} = $util->html_encode($ref->{'note'});
+ $context{note} =~ s/\n/<br\/>/g;
+ $context{created_at} = $util->html_encode($ref->{'created_at'});
+ $context{updated_at} = $util->html_encode($ref->{'updated_at'});
+ $context{assigned_to} = $util->html_encode($ref->{'assigned_to'});
+ $context{processed_by} = $util->html_encode($ref->{'processed_by'});
+ $context{created_by} = $util->html_encode($ref->{'created_by'});
+ $context{status} = $util->html_encode($ref->{'status'});
+ $context{errorString} = $util->html_encode($ref->{'errorString'});
+ $context{id} = $util->html_encode($ref->{'rowid'});
+
+ my $t_st = new Benchmark;
+ my $result = $parser->execute_file_with_context("agent/request/op.vm",
+ \%context);
+ my $t_et = new Benchmark;
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+
+ my $et = new Benchmark;
+
+ $self->debug_log($cfg, "benchmark " .
+ "total=" . timestr(timediff($et, $st)) . " " .
+ "db total=" . timestr(timediff($db_et, $db_st)) . " " .
+ "template total=" . timestr(timediff($t_et, $t_st)) . " "
+ );
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/agent/request/read.cgi b/pki/base/ra/forms/agent/request/read.cgi
new file mode 100755
index 000000000..d1633c164
--- /dev/null
+++ b/pki/base/ra/forms/agent/request/read.cgi
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ if (!$self->agent_auth($cfg)) {
+ print $q->redirect("/agent/error.cgi");
+ return;
+ }
+ my $uid = $self->get_current_uid($cfg);
+
+ my %context;
+ $context{uid} = $util->html_encode($uid);
+
+
+ my @roles = $self->get_current_roles($cfg);
+# my $r = join(",",@roles);
+
+ my $id = $util->get_alphanum_val($q->param('id'));
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $ref = $queue->read_request_by_roles(\@roles, $id);
+ $queue->close();
+
+ $context{data} = $util->breakline($util->html_encode(Encode::decode('UTF-8',$ref->{'data'})), 40);
+ $context{output} = $util->breakline($util->html_encode($ref->{'output'}), 40);
+ $context{meta_info} = $util->breakline($util->html_encode($ref->{'meta_info'}), 40);
+
+ $context{serialno} = $util->html_encode($ref->{'serialno'});
+ $context{subject_dn} = $util->html_encode($ref->{'subject_dn'});
+ $context{type} = $util->html_encode($ref->{'type'});
+ $context{created_at} = $util->html_encode($ref->{'created_at'});
+ $context{created_by} = $util->html_encode($ref->{'created_by'});
+ $context{updated_at} = $util->html_encode($ref->{'updated_at'});
+ $context{ip} = $util->html_encode($ref->{'ip'});
+ $context{processed_by} = $util->html_encode($ref->{'processed_by'});
+ $context{note} = $util->html_encode($ref->{'note'});
+ $context{note} =~ s/\n/<br\/>/g;
+ $context{assigned_to} = $util->html_encode($ref->{'assigned_to'});
+ $context{status} = $util->html_encode($ref->{'status'});
+ if ($ref->{'status'} eq "OPEN") {
+ $context{is_open} = 1;
+ }
+ if ($ref->{'status'} eq "ERROR") {
+ $context{is_error} = 1;
+ }
+ $context{errorString} = $util->html_encode($ref->{'errorString'});
+ $context{id} = $util->html_encode($ref->{'rowid'});
+
+ my $result = $parser->execute_file_with_context("agent/request/read.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/agent/enroll.cgi b/pki/base/ra/forms/ee/agent/enroll.cgi
new file mode 100755
index 000000000..4f1af8f16
--- /dev/null
+++ b/pki/base/ra/forms/ee/agent/enroll.cgi
@@ -0,0 +1,127 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use MIME::Base64;
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use PKI::Conn::CA;
+use PKI::Base::PinStore;
+use PKI::Base::Util;
+
+use vars qw (@ISA);
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $uid = $util->get_val($q->param('uid'));
+ my $pin = $util->get_alphanum_val($q->param('pin'));
+ my $csr = $util->get_val($q->param('csr'));
+ $csr = $util->normalize_csr($csr);
+
+ my $key = $uid;
+
+ my $pin_store = PKI::Base::PinStore->new();
+ $pin_store->open($cfg);
+ my $pinref = $pin_store->read_pin($key);
+ if (defined($pinref) && $pinref->{'pin'} eq $pin) {
+ $pin_store->delete($key);
+ } else {
+ $pin_store->close();
+ print $q->redirect("/ee/error.cgi?error=Invalid Pin");
+ return;
+ }
+ my $rid = $pinref->{'rid'};
+ $pin_store->close();
+
+ my $profile_id = $cfg->get("request.agent.profileId");
+ my $cert_request_type = $cfg->get("request.agent.reqType");
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $req = $queue->read_request($rid);
+ $queue->set_request($rid, "subject_dn", "uid=$uid, e=$req->{'created_by'}");
+
+ my $ca = PKI::Conn::CA->new();
+ $ca->open($cfg);
+ my $cert = $ca->enroll($rid, "ca1", $profile_id, $cert_request_type, $csr);
+ $ca->close();
+ $queue->set_request($rid, "output", $cert);
+
+ $req = $queue->read_request($rid);
+ if ($cert eq "") {
+ my $error = $req->{'errorString'};
+ $queue->close();
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+
+ my $decoded = decode_base64($cert);
+ my $encoded = encode_base64($decoded);
+
+ my %context;
+ $context{cert} = $encoded;
+ $context{rid} = $util->html_encode($rid);
+ $context{subject_dn} = $util->html_encode($req->{'subject_dn'});
+ $queue->close();
+
+ my $result = $parser->execute_file_with_context("ee/agent/enroll.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/agent/index.cgi b/pki/base/ra/forms/ee/agent/index.cgi
new file mode 100755
index 000000000..66fceb8ff
--- /dev/null
+++ b/pki/base/ra/forms/ee/agent/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Registry;
+use Template::Velocity;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/agent/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/agent/new.cgi b/pki/base/ra/forms/ee/agent/new.cgi
new file mode 100755
index 000000000..c209f5e74
--- /dev/null
+++ b/pki/base/ra/forms/ee/agent/new.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Registry;
+use Template::Velocity;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/agent/new.vm", \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/agent/start.cgi b/pki/base/ra/forms/ee/agent/start.cgi
new file mode 100755
index 000000000..27aedb546
--- /dev/null
+++ b/pki/base/ra/forms/ee/agent/start.cgi
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Registry;
+use Template::Velocity;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+
+ my $result = $parser->execute_file_with_context("ee/agent/start.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/agent/submit.cgi b/pki/base/ra/forms/ee/agent/submit.cgi
new file mode 100755
index 000000000..a68242114
--- /dev/null
+++ b/pki/base/ra/forms/ee/agent/submit.cgi
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my $uid = $util->get_val($q->param('uid'));
+ my $email = $util->get_val($q->param('email'));
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $request_id = $queue->create_request("agent",
+ "uid=" . $uid,
+ "0",
+ $email);
+ my %context;
+ $context{request_id} = $util->html_encode($request_id);
+ $self->debug_log($cfg, "request $request_id created");
+ $queue->close();
+
+ my $result = $parser->execute_file_with_context("ee/agent/submit.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/error.cgi b/pki/base/ra/forms/ee/error.cgi
new file mode 100755
index 000000000..1417d4b61
--- /dev/null
+++ b/pki/base/ra/forms/ee/error.cgi
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::UserStore;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $util = PKI::Base::Util->new();
+
+ my %context;
+
+ my $error = $util->get_val($q->param('error'));
+ if ($error ne "") {
+ $context{has_error} = 1;
+ $context{'error'} = $util->html_encode($error);
+ }
+
+ my $result = $parser->execute_file_with_context("ee/error.vm", \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/index.cgi b/pki/base/ra/forms/ee/index.cgi
new file mode 100755
index 000000000..453b2873b
--- /dev/null
+++ b/pki/base/ra/forms/ee/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/index.vm", \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/request/getcert.cgi b/pki/base/ra/forms/ee/request/getcert.cgi
new file mode 100755
index 000000000..b22444dc1
--- /dev/null
+++ b/pki/base/ra/forms/ee/request/getcert.cgi
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use Template::Velocity;
+use MIME::Base64;
+use Encode;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $id = $util->get_alphanum_val($q->param('id'));
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $req = $queue->read_request($id);
+ $queue->close();
+
+ my %context;
+ $context{id} = $util->html_encode($req->{'rowid'});
+ $context{serialno} = $util->html_encode($req->{'serialno'});
+ $context{subject_dn} = $util->html_encode(Encode::decode('UTF-8', $req->{'subject_dn'}));
+ if ($req->{'serialno'} eq "unavailable") {
+ $context{output} = "";
+ } else {
+ $context{output} = "-----BEGIN CERTIFICATE-----\n".$util->breakline($util->html_encode($req->{'output'}), 40)."\n-----END CERTIFICATE-----";
+ }
+ my $result = $parser->execute_file_with_context("ee/request/getcert.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/request/importcert.cgi b/pki/base/ra/forms/ee/request/importcert.cgi
new file mode 100755
index 000000000..fdc309746
--- /dev/null
+++ b/pki/base/ra/forms/ee/request/importcert.cgi
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use Template::Velocity;
+use MIME::Base64;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $id = $util->get_alphanum_val($q->param('id'));
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $req = $queue->read_request($id);
+ $queue->close();
+
+ my %context;
+# $::symbol{id} = $req->{'rowid'};
+# $::symbol{status} = $req->{'status'};
+
+# my $result = $parser->execute_file("ee/request/status.vm");
+
+ my $cert = MIME::Base64::decode($req->{'output'});
+
+ print "Content-Type: application/x-x509-user-cert\n\n";
+ print $cert;
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/request/index.cgi b/pki/base/ra/forms/ee/request/index.cgi
new file mode 100755
index 000000000..ef2a68b23
--- /dev/null
+++ b/pki/base/ra/forms/ee/request/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/request/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/request/status.cgi b/pki/base/ra/forms/ee/request/status.cgi
new file mode 100755
index 000000000..6a3154716
--- /dev/null
+++ b/pki/base/ra/forms/ee/request/status.cgi
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+use Template::Velocity;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+
+ my $util = PKI::Base::Util->new();
+
+ my $id = $util->get_alphanum_val($q->param('id'));
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $req = $queue->read_request($id);
+ $queue->close();
+ if ($req == "") {
+ print $q->redirect("/ee/error.cgi?error=request%20not%20found");
+ return;
+ }
+
+ my %context;
+ $context{id} = $util->html_encode($req->{'rowid'});
+ $context{type} =$util->html_encode($req->{'type'});
+ $context{status} = $util->html_encode($req->{'status'});
+ $context{serialno} = $util->html_encode($req->{'serialno'});
+ $context{errorString} = $util->html_encode($req->{'errorString'});
+
+ my $result = $parser->execute_file_with_context("ee/request/status.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/enroll.cgi b/pki/base/ra/forms/ee/scep/enroll.cgi
new file mode 100755
index 000000000..53291636a
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/enroll.cgi
@@ -0,0 +1,112 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use MIME::Base64;
+use URI::URL;
+use URI::Escape;
+use XML::Simple;
+use CGI;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Conn::CA;
+use PKI::Base::PinStore;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $client_id = $util->get_val($q->param('client_id'));
+ my $site_id = $util->get_val($q->param('site_id'));
+ my $pin = $util->get_alphanum_val($q->param('pin'));
+ my $csr = $util->get_val($q->param('csr'));
+
+ my $key = $client_id . "/" . $site_id;
+
+ my $pin_store = PKI::Base::PinStore->new();
+ $pin_store->open($cfg);
+ my $pinref = $pin_store->read_pin($key);
+ if (defined($pinref) && $pinref->{'pin'} eq $pin) {
+ $pin_store->delete($key);
+ } else {
+ $pin_store->close();
+ # error, redirect user back to the original enrollment page
+ print $q->redirect("/ee/scep/installer.cgi");
+ return;
+ }
+ $pin_store->close();
+
+ my $profile_id = $cfg->get("request.scep.profileId");
+ my $cert_request_type = $cfg->get("request.scep.reqType");
+
+ my $ca = PKI::Conn::CA->new();
+ $ca->open($cfg);
+ my $cert = $ca->enroll($pinref->{'rid'}, "ca1", $profile_id, $cert_request_type, $csr);
+ $ca->close();
+ my $decoded = decode_base64($cert);
+ my $encoded = encode_base64($decoded);
+
+ my %context;
+ $context{cert} = $encoded;
+
+ my $result = $parser->execute_file_with_context("ee/scep/enroll.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/index.cgi b/pki/base/ra/forms/ee/scep/index.cgi
new file mode 100755
index 000000000..c73fc379a
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/scep/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/installer.cgi b/pki/base/ra/forms/ee/scep/installer.cgi
new file mode 100755
index 000000000..8453c2cc4
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/installer.cgi
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my %context;
+ $context{machine} = $cfg->get("service.machineName");
+ $context{port} = $cfg->get("service.unsecurePort");
+
+ my $result = $parser->execute_file_with_context("ee/scep/installer.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/manager.cgi b/pki/base/ra/forms/ee/scep/manager.cgi
new file mode 100755
index 000000000..8b547a928
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/manager.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/scep/manager.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/pkiclient.cgi b/pki/base/ra/forms/ee/scep/pkiclient.cgi
new file mode 100755
index 000000000..a54558f37
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/pkiclient.cgi
@@ -0,0 +1,113 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use MIME::Base64;
+use URI::URL;
+use URI::Escape;
+use XML::Simple;
+use CGI;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Conn::CA;
+use PKI::Base::PinStore;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $operation = $util->get_alphanum_val($q->param('operation'));
+ my $message = $util->get_val($q->param('message'));
+ $message = uri_escape($message);
+
+ my $ca = PKI::Conn::CA->new();
+ $ca->open($cfg);
+ if ($operation eq "GetCACert") {
+ my $content = $ca->scep_get_ca_cert("ca1", $operation, $message);
+
+ print "Content-Type: application/x-x509-ca-cert\n\n";
+ print $content;
+ } elsif ($operation eq "PKIOperation") {
+ my $decoded = $ca->scep_decode("ca1", $operation, $message);
+ $decoded =~ /(\<XMLResponse\>.*\<\/XMLResponse\>)/;
+ $decoded = $1;
+ my $parser = XML::Simple->new();
+ my $response = $parser->XMLin($decoded);
+
+ # one time pin
+ my $pin = $response->{'PKCS10'}->{'ChallengePassword'}->{'Password'} ;
+ # IP Address
+ my $key = $ENV{'REMOTE_ADDR'};
+
+ # check PIN
+ if (1) {
+ my $pin_store = PKI::Base::PinStore->new();
+ $pin_store->open($cfg);
+ my $pinref = $pin_store->read_pin($key);
+ if (defined($pinref) && $pinref->{'pin'} eq $pin) {
+ $pin_store->delete($key);
+ } else {
+ $pin_store->close();
+ # XXX - return SCEP error
+ print $q->redirect("/ee/scep/installer.cgi");
+ return;
+ }
+ $pin_store->close();
+ }
+
+ my $content = $ca->scep_pki_message("ca1", $operation, $message);
+
+ print "Content-Type: application/x-pki-message\n\n";
+ print $content;
+ }
+ $ca->close();
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/scep/submit.cgi b/pki/base/ra/forms/ee/scep/submit.cgi
new file mode 100755
index 000000000..b3dfd7a5d
--- /dev/null
+++ b/pki/base/ra/forms/ee/scep/submit.cgi
@@ -0,0 +1,91 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use DBI;
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $client_id = $util->get_val($q->param('client_id'));
+ my $site_id = $util->get_val($q->param('site_id'));
+ my $email = $util->get_val($q->param('email'));
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $request_id = $queue->create_request("scep",
+ "client_id=" . $client_id . ";" .
+ "site_id=" . $site_id,
+ "0",
+ $email);
+ my %context;
+ $context{request_id} = $util->html_encode($request_id);
+ $self->debug_log($cfg, "request $request_id created");
+ $queue->close();
+
+ my $result = $parser->execute_file_with_context("ee/scep/submit.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/server/admin.cgi b/pki/base/ra/forms/ee/server/admin.cgi
new file mode 100755
index 000000000..18945da02
--- /dev/null
+++ b/pki/base/ra/forms/ee/server/admin.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/server/admin.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/server/index.cgi b/pki/base/ra/forms/ee/server/index.cgi
new file mode 100755
index 000000000..830409a8b
--- /dev/null
+++ b/pki/base/ra/forms/ee/server/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/server/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/server/submit.cgi b/pki/base/ra/forms/ee/server/submit.cgi
new file mode 100755
index 000000000..4916033ee
--- /dev/null
+++ b/pki/base/ra/forms/ee/server/submit.cgi
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Request::Queue;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $util = PKI::Base::Util->new();
+
+ my $server_id = $util->get_val($q->param('server_id'));
+ my $site_id = $util->get_val($q->param('site_id'));
+ my $email = $util->get_val($q->param('email'));
+ my $csr = $util->get_val($q->param('csr'));
+
+ $csr = $util->normalize_csr($csr);
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $request_id = $queue->create_request("server",
+ "server_id=" . $server_id . ";" .
+ "site_id=" . $site_id . ";" .
+ "csr=" . $csr,
+ "0",
+ $email);
+ my %context;
+ $context{request_id} = $util->html_encode($request_id);
+ $self->debug_log($cfg, "request $request_id created");
+ $queue->close();
+
+ my $result = $parser->execute_file_with_context("ee/server/submit.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/user/index.cgi b/pki/base/ra/forms/ee/user/index.cgi
new file mode 100755
index 000000000..ef6b3aa47
--- /dev/null
+++ b/pki/base/ra/forms/ee/user/index.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/user/index.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/user/renew.cgi b/pki/base/ra/forms/ee/user/renew.cgi
new file mode 100755
index 000000000..63d646ec9
--- /dev/null
+++ b/pki/base/ra/forms/ee/user/renew.cgi
@@ -0,0 +1,165 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Base::Conf;
+use PKI::Request::Queue;
+use Template::Velocity;
+use PKI::Service::Op;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my $util = PKI::Base::Util->new();
+ my $error = "";
+
+ my $host = $cfg->get("service.machineName");
+ my $port = $cfg->get("service.non_clientauth_securePort");
+
+ $self->debug_params($cfg, $q);
+
+ my $cert = $self->get_cert_record($cfg);
+ $self->debug_log( $cfg, "after get_cert_record");
+ if (!defined($cert) || ($cert eq "")) {
+ $self->debug_log( $cfg, "cert not defined");
+ $error = "certificate not found in database";
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+ $self->debug_log( $cfg, "got cert");
+
+ my $csr = $cert->{'csr'};
+ if ($csr eq "") {
+ $error = "csr not found in database";
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+ $self->debug_log( $cfg, "got csr");
+
+ my $req_id = $cert->{'rid'};
+ if ($req_id eq "") {
+ $error = "reqid not found in database";
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+ $self->debug_log( $cfg, "got req_id = $req_id");
+ $self->debug_log( $cfg, "before renewl read/create request");
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $o_req = $queue->read_request($req_id);
+ if ($o_req eq "") {
+ $self->debug_log( $cfg, "got null o_req");
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+
+ my $uid = "";
+ my $site_id = "";
+ my $org_csr = "";
+ my $csr_type = "";
+
+ my $data = $o_req->{'data'};
+ foreach $nv (split(/;/, $data)) {
+ my ($n, $v) = split(/=/, $nv);
+ if ($n eq "uid") {
+ $uid = $v;
+ }
+ if ($n eq "site_id") {
+ $site_id = $v;
+ }
+ if ($n eq "csr") {
+ $org_csr = $v;
+ }
+ if ($n eq "csr_type") {
+ $csr_type = $v;
+ }
+ }
+
+ my $new_request = $queue->create_request("renewal",
+ "uid=" . $uid . ";" .
+ "site_id=" . $site_id . ";" .
+ "csr_type=" . $csr_type . ";" .
+ "csr=" . $csr,
+ "orig_reqid=" . $o_req->{'rowid'},
+ $o_req->{'created_by'});
+
+ #self-renewal is created and processed by the same user
+ $ref = $queue->approve_request($new_request, $o_req->{'created_by'});
+ my $nreq = $queue->read_request($new_request);
+ $error = $nreq->{'errorString'};
+ if ($error ne "0") {
+ $self->debug_log( $cfg, "after approve request, got error=$error");
+ print $q->redirect("/ee/error.cgi?error=$error");
+ return;
+ }
+
+ my %context;
+ $context{request_id} = $util->html_encode($new_request);
+ $self->debug_log($cfg, "request $new_request created");
+ $queue->close();
+ $self->debug_log( $cfg, "after renewl read/create request $new_request");
+
+ $context{data} = $util->breakline($util->html_encode($ref->{'data'}), 40);
+ $context{output} = $util->breakline($util->html_encode($ref->{'output'}), 40);
+ $context{serialno} = $util->html_encode($ref->{'serialno'});
+ $context{host} = $util->html_encode($host);
+ $context{port} = $util->html_encode($port);
+
+ #print $q->redirect("/ee/request/getcert.cgi?id=$new_request");
+ my $result = $parser->execute_file_with_context("ee/user/renew.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/user/renewal.cgi b/pki/base/ra/forms/ee/user/renewal.cgi
new file mode 100755
index 000000000..63a211eff
--- /dev/null
+++ b/pki/base/ra/forms/ee/user/renewal.cgi
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $host = $cfg->get("service.machineName");
+ my $port = $cfg->get("service.securePort");
+
+ my %context;
+ $context{url} = "https://$host:$port/ee/user/renew.cgi";
+ my $result = $parser->execute_file_with_context("ee/user/renewal.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/user/submit.cgi b/pki/base/ra/forms/ee/user/submit.cgi
new file mode 100755
index 000000000..26c900e00
--- /dev/null
+++ b/pki/base/ra/forms/ee/user/submit.cgi
@@ -0,0 +1,112 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use Benchmark;
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Util;
+use PKI::Base::Registry;
+use PKI::Request::Queue;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $st = new Benchmark;
+
+ my $util = PKI::Base::Util->new();
+
+ my $userid = $util->get_val($q->param('uid'));
+ my $fullname = $util->get_val($q->param('cn'));
+ my $site_id = $util->get_val($q->param('site_id'));
+ my $email = $util->get_val($q->param('email'));
+ my $csr_type = $util->get_alphanum_val($q->param('csr_type'));
+ my $csr = $util->get_val($q->param('csr'));
+
+ $csr = $util->normalize_csr($csr);
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ my $db_st = new Benchmark;
+ my $queue = PKI::Request::Queue->new();
+ $queue->open($cfg);
+ my $request_id = $queue->create_request("user",
+ "uid=" . $userid . ";" .
+ "cn=" . $fullname . ";" .
+ "site_id=" . $site_id . ";" .
+ "csr_type=" . $csr_type . ";" .
+ "csr=" . $csr,
+ "0",
+ $email);
+ my %context;
+ $context{request_id} = $util->html_encode($request_id);
+ $self->debug_log($cfg, "request $request_id created");
+ $queue->close();
+ my $db_et = new Benchmark;
+
+ my $t_st = new Benchmark;
+ my $result = $parser->execute_file_with_context("ee/user/submit.vm",
+ \%context);
+ my $t_et = new Benchmark;
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+
+ my $et = new Benchmark;
+ $self->debug_log($cfg, "benchmark " .
+ "total=" . timestr(timediff($et, $st)) . " " .
+ "db total=" . timestr(timediff($db_et, $db_st)) . " " .
+ "template total=" . timestr(timediff($t_et, $t_st)) . " "
+ );
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/ee/user/user.cgi b/pki/base/ra/forms/ee/user/user.cgi
new file mode 100755
index 000000000..2d58a532b
--- /dev/null
+++ b/pki/base/ra/forms/ee/user/user.cgi
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ my %context;
+ my $result = $parser->execute_file_with_context("ee/user/user.vm",
+ \%context);
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%context);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+my $op = op->new();
+$op->execute();
diff --git a/pki/base/ra/forms/index.cgi b/pki/base/ra/forms/index.cgi
new file mode 100755
index 000000000..0e643166b
--- /dev/null
+++ b/pki/base/ra/forms/index.cgi
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program 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; version 2 of the License.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+#
+#
+#
+
+package op;
+
+use lib $ENV{DOCUMENT_ROOT} . "/../lib/perl";
+
+use CGI;
+use PKI::Service::Op;
+use Template::Velocity;
+use PKI::Base::Conf;
+use PKI::Base::Registry;
+
+use vars qw (@ISA);
+use PKI::Service::Op;
+@ISA = qw(PKI::Service::Op);
+
+sub new {
+ my $self = {};
+ bless ($self);
+ return $self;
+}
+
+sub process()
+{
+ my $self = shift;
+
+ my $q = CGI->new();
+
+ my $docroot = PKI::Base::Registry->get_docroot();
+ my $parser = PKI::Base::Registry->get_parser();
+ my $cfg = PKI::Base::Registry->get_config();
+
+ $self->debug_params($cfg, $q);
+
+ $::symbol{machineName} = $cfg->get("service.machineName");
+ $::symbol{non_clientauth_securePort} = $cfg->get("service.non_clientauth_securePort");
+ $::symbol{securePort} = $cfg->get("service.securePort");
+ $::symbol{unsecurePort} = $cfg->get("service.unsecurePort");
+
+ my $result = $parser->execute_file("index.vm");
+
+ my $xml = $q->param('xml');
+ if ($xml eq "true") {
+ print "Content-Type: text/xml\n\n";
+ print $self->xml_output(\%::symbol);
+ } else {
+ print "Content-Type: text/html\n\n";
+ print "$result";
+ }
+}
+
+
+my $op = op->new();
+$op->execute();