%args>
$email => undef
$subject => undef
$issuer => undef
$cert_serial => undef
$csr_serial => undef
$limit => 10
$start => 1
$page => undef
$revocation => undef
%args>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_CERT_LIST_TITLE') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_CERT_LIST_DESCRIPTION') %>
% if (scalar @results == 0) {
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_CERT_LIST_NO_CERTIFICATES_FOUND') %>
% return;
% }
<% i18nGettext('I18N_OPENXPKI_CERT_SERIAL') %> |
<% i18nGettext('I18N_OPENXPKI_HTML_COMMON_NAME') %> |
<% i18nGettext('I18N_OPENXPKI_CERT_EMAIL') %> |
<% i18nGettext('I18N_OPENXPKI_CERT_NOTBEFORE') %> |
<% i18nGettext('I18N_OPENXPKI_CERT_NOTAFTER') %> |
<% i18nGettext('I18N_OPENXPKI_CERT_ISSUER') %> |
% foreach my $cert (@results) {
% my $notbefore = OpenXPKI::DateTime::convert_date({
% DATE => DateTime->from_epoch(epoch => $cert->{NOTBEFORE}),
% });
% $notbefore =~ s/T/ /;
% $notbefore .= ' UTC';
% my $notafter = OpenXPKI::DateTime::convert_date({
% DATE => DateTime->from_epoch(epoch => $cert->{NOTAFTER}),
% });
% $notafter =~ s/T/ /;
% $notafter .= ' UTC';
<& /lib/html/a.mhtml,
'target' => "cert_info.html",
'params' => [
["identifier", $cert->{IDENTIFIER}],
['revocation', $revocation],
],
'label' => $cert->{CERTIFICATE_SERIAL} &>
|
<% $cert->{CN} %>
|
<% $cert->{EMAIL} %>
|
<% $notbefore %>
|
<% $notafter %>
|
<% $cert->{'ISSUER_DN'} %>
|
% }
<& /service/create_csr/print_errors.mhtml, 'errors' => \@errors &>
<%init>
## if $subject is not defined then define it as $subject = '*'
## This will influence nothing if any other field is defined.
## But there will not be an error if noone field is defined,
## instead all certificates will be shown
if (!(defined $subject and length $subject)) {
$subject = '*';
}
## collect params
my %fields = ();
$fields{'EMAIL'} = "*$email*" if (defined $email and length $email);
$fields{'SUBJECT'} = "*$subject*" if (defined $subject and length $subject);
$fields{'ISSUER'} = "*$issuer*" if (defined $issuer and length $issuer);
$fields{'CERT_SERIAL'} = $cert_serial if (defined $cert_serial and length $cert_serial);
$fields{'CSR_SERIAL'} = $csr_serial if (defined $csr_serial and length $csr_serial);
my $result_count = $context->{client}->send_receive_command_msg(
'search_cert_count', \%fields
)->{PARAMS};
my $page_info = $m->comp('/lib/paging.mhtml',
totalEntries => $result_count,
entriesPerPage => $limit,
page => $page,
start => $start,
url => 'cert_list.html',
);
if (defined $page_info) {
$fields{'START'} = $page_info->first - 1;
}
if ($fields{'START'} == -1) {
$fields{'START'} = 1;
}
$fields{'LIMIT'} = $limit;
## execute query
my $msg = $context->{client}->send_receive_command_msg (
"search_cert", \%fields);
## error or result ?
my %list = ();
my @errors = ();
my @results = ();
if (not exists $msg->{PARAMS} or ref $msg->{PARAMS} ne 'ARRAY')
{
push @errors, @{$msg->{LIST}};
}
else
{
@results = @{ $msg->{PARAMS} };
if (scalar @{$msg->{PARAMS}} == 1) { # we have only one result, show
# it directly
$m->comp('cert_info.html',
'identifier' => $msg->{PARAMS}->[0]->{IDENTIFIER},
'revocation' => $revocation,
);
return;
}
}
foreach my $cert (@results) {
my $cn = '';
my %dn_hash = OpenXPKI::DN->new($cert->{SUBJECT})->get_hashed_content();
$cn = $dn_hash{'CN'}->[0];
$cert->{CN} = $cn;
}
%init>
<%once>
use OpenXPKI::DateTime;
use DateTime;
%once>