RT notifier: parse templates without header correctly
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / htdocs / binary / get_certificate.html
blob0f0736c9e512d2b26866efb7b4df0827d8acc78b
1 <%args>
2 $identifier => undef
3 $content_type => "PLAIN"
4 $format => "PEM"
5 </%args>
7 <%init>
8 ## first we have to determine the content-type
9 my $attachment = 1;
10 switch ($content_type)
12 case "X509_CA_CERT" {$content_type = "application/x-x509-ca-cert"; $attachment = 0; }
13 case "X509_USER_CERT" {$content_type = "application/x-x509-user-cert"; $attachment = 0; }
14 case "X509_EMAIL_CERT" {$content_type = "application/x-x509-email-cert"; $attachment = 0; }
15 case "IE_CA" {$content_type = "application/x-x509-ca-cert"}
16 case "IE_USER" {$content_type = "application/x-x509-user-cert"}
17 case "PLAIN" {$content_type = "text/plain"; $attachment = 0;}
18 case "DOWNLOAD" {$content_type = "application/octet-string"}
19 else {
20 print "<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_CERT_WRONG_CONTENT_TYPE_TITLE')."</h1>\n";
21 print "<p>\n";
22 print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_CERT_WRONG_CONTENT_TYPE_DESC',
23 '__CONTENT_TYPE__' => $content_type)."\n";
24 print "</p>\n";
25 return 1;
29 ## second we have to check the format
30 my $native = "";
31 my $extension = "";
32 switch ($format)
34 case "PKCS7" {$native = "PKCS7"; $extension = 'p7'; }
35 case "TXT" {$native = "TXT"; $extension = 'txt'; }
36 case "DER" {$native = "DER"; $extension = 'der'; }
37 case "PEM" {$native = "PEM"; $extension = 'pem'; $attachment = 1; }
38 case "IE_ENROLL" {$native = "PEM"; $extension = 'pem'; } # ???
39 else {
40 print "<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_CERT_WRONG_FORMAT_TITLE')."</h1>\n";
41 print "<p>\n";
42 print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_CERT_WRONG_FORMAT_DESC',
43 '__FORMAT__' => $format)."\n";
44 print "</p>\n";
45 return 1;
49 if ($format eq 'PEM' && $content_type ne 'DOWNLOAD') {
50 # Mozilla certificate installation has to be sent inline
51 $attachment = 0;
53 my $filename = $m->comp('/lib/filename_for_cert.mhtml',
54 'identifier' => $identifier,
55 'extension' => $extension,
58 ## now request the certificate from the server
59 my $msg = $context->{client}->send_receive_command_msg (
60 "get_cert",
61 {'IDENTIFIER' => $identifier,
62 'FORMAT' => $native});
63 my $item = $msg->{PARAMS};
65 ## now send the stuff
66 if ($attachment) {
67 eval {
68 $r->header_out('Content-Disposition' => ("attachment; filename=$filename"));
70 if ($EVAL_ERROR) {
71 # mod_perl 2
72 $r->headers_out->add('Content-Disposition' => ("attachment; filename=$filename"));
75 $r->content_type ($content_type);
76 print $item;
77 return 1;
78 </%init>
79 <%once>
80 use Switch;
81 use English;
82 </%once>