App-CamelPKI
view release on metacpan or search on metacpan
lib/App/CamelPKI/Controller/CA/Template/Base.pm view on Meta::CPAN
my ($self, $c) = @_;
$c->stash->{template} = $self->_form_revoke_template;
}
=head2 revoke
Revokes a set of certificates at once. The datas are passed by a form.
$c->request->params->{type}="dns"
$c->request->params->{data}="foo.bar.com"
The effect is to revoke all certificates that have foo.bar.com as their DNS
name in any of the templates that this controller class deals with.
=cut
sub revoke : Local {
my ($self, $c) = @_;
my $ca = $c->model("CA")->instance;
my $type = $c->request->params->{type};
my $data = $c->request->params->{data};
foreach my $shorttemplate ($self->_list_template_shortnames()) {
my $template = "App::CamelPKI::CertTemplate::$shorttemplate";
my @revocation_criteria =
map { ($type =~ m/$_/) ?
($_ => $data) :
() } ($self->_revocation_keys);
throw App::CamelPKI::Error::User
("Attempt revoke whole template group")
if ! @revocation_criteria;
warn @revocation_criteria;
$ca->revoke($template, $_)
for $ca->database->search
(template => $template, @revocation_criteria);
}
$ca->commit;
$c->stash->{type}=$type;
$c->stash->{data}=$data;
$c->stash->{template} = "certificate/revocation_done.tt2";
}
=head2 revokeJSON($revocdetails)
Revokes a set of certificates at once. The $revocdetails structure is
of the following form:
{
dns => $host
}
The effect is to revoke all certificates that have $host as their DNS
name in any of the templates that this controller class deals with.
=cut
sub revokeJSON : Local : ActionClass("+App::CamelPKI::Action::JSON") {
my ($self, $c, $revocdetails) = @_;
print "\n\n\n 1-- ".Data::Dumper::Dumper($self->_revocation_keys."\n\n\n");
my $ca = $c->model("CA")->instance;
foreach my $shorttemplate ($self->_list_template_shortnames()) {
my $template = "App::CamelPKI::CertTemplate::$shorttemplate";
my @revocation_criteria =
map { exists($revocdetails->{$_}) ?
($_ => $revocdetails->{$_}) :
() } ($self->_revocation_keys);
throw App::CamelPKI::Error::User
("Attempt revoke whole template group")
if ! @revocation_criteria;
$ca->revoke($template, $_)
for $ca->database->search
(template => $template, @revocation_criteria);
}
$ca->commit;
}
=head2 view_operations
returns to the right view for listing possiblities with templates.
=cut
sub view_operations : Local {
my ($self, $c) = @_;
$c->stash->{template} = $self->_operations_available;
}
=head1 OVERLOADABLE METHODS
=head2 _list_template_shortnames
Shall return the list of the short names of the templates that this
controller deals with. There is no base class implementation.
=cut
# No base class implementation
=head2 _revocation_keys
Shall return the list of nominative data keys that are allowed as
criteria for batch revocation. The base class implementation is to
use only C<dns>.
=cut
sub _revocation_keys { "dns" }
1;
( run in 2.298 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )