<%args>
  $identifier => undef
</%args>
<h1>
  <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_CHAIN_LIST_TITLE') %>
</h1>
<p>
  <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_CHAIN_LIST_DESCRIPTION') %>
</p>
<p>
  <& /lib/html/a.mhtml,
     'target' => "../../binary/get_chain.html",
     'params' => [["identifier", $identifier]],
     'label'  => i18nGettext('I18N_OPENXPKI_DOWNLOAD_CHAIN') &>
</p>
<table id="table_list">
  <tr>
    <th><% i18nGettext('I18N_OPENXPKI_CERT_SUBJECT') %></th>
    <th><% i18nGettext('I18N_OPENXPKI_CERT_NOTBEFORE') %></th>
    <th><% i18nGettext('I18N_OPENXPKI_CERT_NOTAFTER') %></th>
  </tr>
<%perl>
  foreach my $ca (sort keys %list)
  {
    print "  <tr>\n";
    print "    <td>\n";
</%perl>
        <& /lib/html/a.mhtml,
           'target' => "ca_cert_info.html",
           'params' => [["identifier", $ca]],
           'label'  => $list{$ca}->{BODY}->{SUBJECT} &>
<%perl>
    print "    </td>\n";
    print "    <td>\n";
    print "      ".join (" ", split "T", $list{$ca}->{BODY}->{NOTBEFORE})." UTC\n";
    print "    </td>\n";
    print "    <td>\n";
    print "      ".join (" ", split "T", $list{$ca}->{BODY}->{NOTAFTER})." UTC\n";
    print "    </td>\n";
    print "  <tr>\n";
  }
</%perl>
</table>
<%init>
  my $msg  = $context->{client}->send_receive_command_msg (
                  "get_chain",
                  {'START_IDENTIFIER' => $identifier});
  my $complete = $msg->{PARAMS}->{COMPLETE};
  my %list     = ();
  foreach my $ca (@{$msg->{PARAMS}->{IDENTIFIERS}})
  {
    $msg  = $context->{client}->send_receive_command_msg (
                 'get_ca_cert',
                 {'IDENTIFIER' => $ca});
    $list{$ca} = $msg->{PARAMS};
  }
</%init>
