RT notifier: parse templates without header correctly
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / htdocs / binary / get_privkey.html
blob79423e9d2e1b6bdece0fc9ff949779258ee395de
1 <%args>
2 $identifier => undef
3 $format => "PKCS8_PEM"
4 $password => undef
5 $csp => undef
6 $csp_freeform => undef
7 </%args>
8 <%init>
9 ## first we have to determine the content-type
10 my $content_type;
11 my $extension;
12 switch ($format) {
13 case "PKCS8_PEM" {$content_type = "text/plain"; $extension = "pem"}
14 case "PKCS8_DER" {$content_type = "application/octet-string"; $extension = "pk8"}
15 case "OPENSSL_PRIVKEY" {$content_type = "text/plain"; $extension = "pem"}
16 case "PKCS12" {$content_type = "application/octet-string"; $extension = "p12"}
17 case "JAVA_KEYSTORE" {$content_type = "application/octet-string"; $extension = "jks"}
18 else {
19 print "<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_TITLE')."</h1>\n";
20 print "<p>\n";
21 print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_DESC',
22 '__FORMAT__' => $format)."\n";
23 print "</p>\n";
24 return 1;
28 if (defined $password) {
29 ## now request the key from the server
30 my $params = {
31 'IDENTIFIER' => $identifier,
32 'FORMAT' => $format,
33 'PASSWORD' => $password,
35 if (defined $csp_freeform && $csp_freeform ne '') {
36 $params->{'CSP'} = $csp_freeform;
38 elsif (defined $csp && $csp ne '') {
39 $params->{'CSP'} = $csp;
41 my $msg = $context->{client}->send_receive_command_msg (
42 "get_private_key_for_cert",
43 $params,
45 my $item = $msg->{PARAMS}->{PRIVATE_KEY};
47 if (!defined $item || $item eq '') {
48 print "<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_TITLE')."</h1>\n";
49 print "<p>\n";
50 print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_DESC');
51 print "</p>\n";
52 return 1;
54 ## now send the stuff
55 my $filename = $m->comp('/lib/filename_for_cert.mhtml',
56 'identifier' => $identifier,
57 'extension' => $extension,
60 eval {
61 $r->header_out('Content-Disposition' => ("attachment; filename=$filename"));
63 if ($EVAL_ERROR) {
64 # mod_perl 2
65 $r->headers_out->add('Content-Disposition' => ("attachment; filename=$filename"));
67 $r->content_type ($content_type);
68 print $item;
69 return 1;
71 </%init>
72 <%once>
73 use Switch;
74 use English;
75 </%once>