From b7413b39ead7974611f0a749240ac5383d011442 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sat, 12 Apr 2014 04:11:50 +0000 Subject: Changes to use new htmlviewfunctions functions --- openssl-checkenvironment-html.lsp | 8 +-- openssl-model.lua | 10 ++-- openssl-putcacert-html.lsp | 9 +-- openssl-read-html.lsp | 114 +++++++++++++++++++++++--------------- openssl-status-html.lsp | 52 +++++++++-------- openssl-viewcert-html.lsp | 6 +- openssl-viewrequest-html.lsp | 6 +- 7 files changed, 118 insertions(+), 87 deletions(-) diff --git a/openssl-checkenvironment-html.lsp b/openssl-checkenvironment-html.lsp index 3475bbc..ae54a17 100644 --- a/openssl-checkenvironment-html.lsp +++ b/openssl-checkenvironment-html.lsp @@ -1,15 +1,15 @@ -<% local form, viewlibrary, page_info = ... %> +<% local form, viewlibrary, page_info, session = ... %> <% htmlviewfunctions = require("htmlviewfunctions") %> <% html = require("acf.html") %> -

<%= html.html_escape(form.label) %>

<% +local header_level = htmlviewfunctions.displaysectionstart(form, page_info) if form.value.status.errtxt then - form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action - htmlviewfunctions.displayformstart(form) + htmlviewfunctions.displayformstart(form, page_info) end htmlviewfunctions.displayitem(form.value.status) if form.value.status.errtxt then htmlviewfunctions.displayformend(form) end +htmlviewfunctions.displaysectionend(header_level) %> diff --git a/openssl-model.lua b/openssl-model.lua index 1df9b13..f5ab354 100644 --- a/openssl-model.lua +++ b/openssl-model.lua @@ -299,7 +299,7 @@ mymodule.getstatus = function() end end local environment = mymodule.checkenvironment() - return cfe({ type="group", value={version=version, conffile=conffile, environment=environment, cacert=cacert, cacertcontents=cacertcontents, cakey=cakey}, label="openssl status" }) + return cfe({ type="group", value={version=version, conffile=conffile, environment=environment, cacert=cacert, cacertcontents=cacertcontents, cakey=cakey}, label="OpenSSL status" }) end mymodule.set_umask = function() @@ -463,7 +463,7 @@ mymodule.viewrequest = function(request) local reqpath = requestdir .. request local cmdresult = modelfunctions.run_executable({"openssl", "req", "-in", reqpath..".csr", "-text", "-noout"}) local a,b,c = string.match(request, "([^%.]*)%.([^%.]*)%.([^%.]*)") - local request = cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, value=cmdresult}, label="Request" }) + local request = cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, value=cmdresult}, label="Request Details" }) return request end @@ -586,7 +586,7 @@ end mymodule.viewcert = function(cert) local cmdresult = modelfunctions.run_executable({"openssl", "x509", "-in", certdir..cert..".crt", "-noout", "-text"}) local a,b,c,d = string.match(cert, "([^%.]*)%.([^%.]*)%.([^%.]*).([^%.]*)") - return cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, serial=d, value=cmdresult}, label="Certificate" }) + return cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, serial=d, value=cmdresult}, label="Certificate Details" }) end mymodule.getcert = function(cert) @@ -728,8 +728,8 @@ mymodule.getca = function(certtype) end mymodule.getnewputca = function() - local ca = cfe({ type="raw", value=0, label="CA Certificate", descr='File must be a password protected ".pfx" file' }) - local password = cfe({ label="Certificate Password" }) + local ca = cfe({ type="raw", value=0, label="CA Certificate", descr='File must be a password protected ".pfx" file', seq=1 }) + local password = cfe({ type="password", label="Certificate Password", seq=2 }) return cfe({ type="group", value={ca=ca, password=password} }) end diff --git a/openssl-putcacert-html.lsp b/openssl-putcacert-html.lsp index 1d178fe..35d39b6 100644 --- a/openssl-putcacert-html.lsp +++ b/openssl-putcacert-html.lsp @@ -1,13 +1,8 @@ -<% local form, viewlibrary, page_info = ... %> +<% local form, viewlibrary, page_info, session = ... %> <% htmlviewfunctions = require("htmlviewfunctions") %> -<% html = require("acf.html") %> -

<%= html.html_escape(form.label) %>

<% - form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action form.enctype = "multipart/form-data" form.value.ca.type="file" - form.value.password.type="password" - local order = {"ca", "password"} - htmlviewfunctions.displayform(form, order) + htmlviewfunctions.displayitem(form, page_info) %> diff --git a/openssl-read-html.lsp b/openssl-read-html.lsp index a3dd4b3..3f4693a 100644 --- a/openssl-read-html.lsp +++ b/openssl-read-html.lsp @@ -24,7 +24,13 @@ <% htmlviewfunctions.displaycommandresults({"approve", "deleterequest", "deletemyrequest", "renewcert", "requestrenewcert", "revoke", "deletecert"}, session) %> -

Pending certificate requests<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %>

+<% +local label = "" +if view.value.user then + label = label.." for "..html.html_escape(view.value.user.value) +end +local header_level = htmlviewfunctions.displaysectionstart(cfe({label="Pending certificate requests"..label}), page_info) +%> <% if not view.value.pending or #view.value.pending.value == 0 then %>

No certificates pending

<% else %> @@ -38,20 +44,24 @@ + <% local req = cfe({ type="hidden", value="" }) %> <% for i,request in ipairs(view.value.pending.value) do %> - <% if viewlibrary.check_permission("viewrequest") then - io.write(html.link{value="viewrequest?request="..request.name, label="View "}) - end %> - <% if viewlibrary.check_permission("approve") then - io.write(html.link{value="approve?submit=true&request="..request.name, label="Approve "}) - end %> - <% if viewlibrary.check_permission("deleterequest") then - io.write(html.link{value="deleterequest?submit=true&request="..request.name, label="Delete "}) + <% + req.value = request.name + if viewlibrary.check_permission("viewrequest") then + htmlviewfunctions.displayitem(cfe({type="link", value={request=req}, label="", option="View", action="viewrequest"}), page_info, -1) + end + if viewlibrary.check_permission("approve") then + htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Approve", action="approve"}), page_info, -1) + end + if viewlibrary.check_permission("deleterequest") then + htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Delete", action="deleterequest"}), page_info, -1) elseif viewlibrary.check_permission("deletemyrequest") then - io.write(html.link{value="deletemyrequest?submit=true&request="..request.name, label="Delete "}) - end %> + htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Delete", action="deletemyrequest"}), page_info, -1) + end + %> <%= html.html_escape(request.user) %> <%= html.html_escape(request.certtype) %> @@ -61,6 +71,9 @@ <% end %> +<% htmlviewfunctions.displaysectionend(header_level) %> + +<% viewtype = cfe({type="hidden", value="stream"}) %> <% local reverserevoked = {} local approved = {} @@ -80,7 +93,7 @@ else approved = view.value.approved.value end %> -

Approved certificate requests<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %>

+<% htmlviewfunctions.displaysectionstart(cfe({label="Approved certificate requests"..label}), page_info, header_level) %> <% if #approved == 0 then %>

No certificates approved

<% else %> @@ -96,26 +109,30 @@ end %> + <% local crt = cfe({ type="hidden", value="" }) %> <% for i,cert in ipairs(approved) do %> class='error'<% end %>> - <% if viewlibrary.check_permission("viewcert") then %> - <%= html.link{value="viewcert?cert="..cert.name, label="View "} %> - <% end %> - <% if viewlibrary.check_permission("getcert") then %> - <%= html.link{value="getcert?viewtype=stream&cert="..cert.name, label="Download "} %> - <% end %> - <% if viewlibrary.check_permission("renewcert") then %> - <%= html.link{value="renewcert?submit=true&cert="..cert.name, label="Renew "} %> - <% elseif viewlibrary.check_permission("requestrenewcert") then %> - <%= html.link{value="requestrenewcert?submit=true&cert="..cert.name, label="Renew "} %> - <% end %> - <% if viewlibrary.check_permission("revoke") then %> - <%= html.link{value="revoke?submit=true&cert="..cert.name, label="Revoke "} %> - <% end %> - <% if viewlibrary.check_permission("deletecert") then %> - <%= html.link{value="deletecert?submit=true&cert="..cert.name, label="Delete "} %> - <% end %> + <% + crt.value = cert.name + if viewlibrary.check_permission("viewcert") then + htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt}, label="", option="View", action="viewcert"}), page_info, -1) + end + if viewlibrary.check_permission("getcert") then + htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt, viewtype=viewtype}, label="", option="Download", action="getcert"}), page_info, -1) + end + if viewlibrary.check_permission("renewcert") then + htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Renew", action="renewcert"}), page_info, -1) + elseif viewlibrary.check_permission("requestrenewcert") then + htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Renew", action="requestrenewcert"}), page_info, -1) + end + if viewlibrary.check_permission("revoke") then + htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Revoke", action="revoke"}), page_info, -1) + end + if viewlibrary.check_permission("deletecert") then + htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Delete", action="deletecert"}), page_info, -1) + end + %> <%= html.html_escape(cert.user) %> <%= html.html_escape(cert.certtype) %> @@ -127,8 +144,9 @@ end %> <% end %> +<% htmlviewfunctions.displaysectionend(header_level) %> -

Revoked certificates<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %>

+<% htmlviewfunctions.displaysectionstart(cfe({label="Revoked certificates"..label}), page_info, header_level) %> <% if #revoked == 0 then %>

No certificates revoked

<% else %> @@ -143,18 +161,22 @@ end %> + <% local crt = cfe({ type="hidden", value="" }) %> <% for i,cert in ipairs(revoked) do %> - <% if viewlibrary.check_permission("viewcert") then %> - <%= html.link{value="viewcert?cert="..cert.name, label="View "} %> - <% end %> - <% --[[ if viewlibrary.check_permission("getcert") then %> - <%= html.link{value="getcert?viewtype=stream&cert="..cert.name, label="Download "} %> - <% end --]] %> - <% if viewlibrary.check_permission("deletecert") then %> - <%= html.link{value="deletecert?submit=true&cert="..cert.name, label="Delete "} %> - <% end %> + <% + crt.value = cert.name + if viewlibrary.check_permission("viewcert") then + htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt}, label="", option="View", action="viewcert"}), page_info, -1) + end + --[[ if viewlibrary.check_permission("getcert") then + htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt, viewtype=viewtype}, label="", option="Download", action="getcert"}), page_info, -1) + end --]] + if viewlibrary.check_permission("deletecert") then + htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Delete", action="deletecert"}), page_info, -1) + end + %> <%= html.html_escape(cert.user) %> <%= html.html_escape(cert.certtype) %> @@ -165,9 +187,13 @@ end %> <% end %> +<% htmlviewfunctions.displaysectionend(header_level) %> -<% if viewlibrary.check_permission("getrevoked") then %> -

Get revoked list (crl)

-<%= html.link{value="getrevoked?viewtype=stream&crltype=PEM", label="Download PEM "} %>
-<%= html.link{value="getrevoked?viewtype=stream&crltype=DER", label="Download DER "} %>
-<% end %> +<% +if viewlibrary.check_permission("getrevoked") then + htmlviewfunctions.displaysectionstart(cfe({label="Get revoked list (crl)"}), page_info, header_level) + htmlviewfunctions.displayitem(cfe({type="link", value={crltype=cfe({type="hidden", value="PEM"}), viewtype=viewtype}, label="", option="Download PEM", action="getrevoked"}), page_info, -1) + htmlviewfunctions.displayitem(cfe({type="link", value={crltype=cfe({type="hidden", value="DER"}), viewtype=viewtype}, label="", option="Download DER", action="getrevoked"}), page_info, -1) + htmlviewfunctions.displaysectionend(header_level) +end +%> diff --git a/openssl-status-html.lsp b/openssl-status-html.lsp index cb02df8..796d63a 100644 --- a/openssl-status-html.lsp +++ b/openssl-status-html.lsp @@ -5,32 +5,33 @@ <% htmlviewfunctions.displaycommandresults({"checkenvironment", "putcacert", "generatecacert"}, session, true) %> <% htmlviewfunctions.displaycommandresults({"install"}, session) %> -

System Info

<% +local header_level = htmlviewfunctions.displaysectionstart(view, page_info) + htmlviewfunctions.displayitem(view.value.version) if view.value.version and view.value.version.errtxt and viewlibrary.check_permission("apk-tools/apk/install") then + local install = cfe({ type="form", value={}, label="Install package", option="Install", action=page_info.script.."/apk-tools/apk/install" }) + install.value.package = cfe({ type="hidden", value=view.value.version.name }) + htmlviewfunctions.displayitem(install, page_info, 0) -- header_level 0 means display inline without header +end + +htmlviewfunctions.displayitem(view.value.conffile) +htmlviewfunctions.displayitem(view.value.environment) +htmlviewfunctions.displayitem(view.value.cacert) +htmlviewfunctions.displayitem(view.value.cakey) %> -

Install package

-
-
" method="post"> - -
-
-<% end %> -<% htmlviewfunctions.displayitem(view.value.conffile) %> -<% htmlviewfunctions.displayitem(view.value.environment) %> -<% htmlviewfunctions.displayitem(view.value.cacert) %> -<% htmlviewfunctions.displayitem(view.value.cakey) %> -<% if not view.value.version.errtxt and not view.value.conffile.errtxt then +<% +if not view.value.version.errtxt and not view.value.conffile.errtxt then if view.value.environment.errtxt then if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("checkenvironment") then viewlibrary.dispatch_component("checkenvironment") end - elseif not view.value.cacert.errtxt and not view.value.cakey.errtxt then %> -

CA Certificate contents

-
<%= html.html_escape(view.value.cacertcontents.value) %>
- <% elseif viewlibrary and viewlibrary.dispatch_component then + elseif not view.value.cacert.errtxt and not view.value.cakey.errtxt then + htmlviewfunctions.displaysectionstart(view.value.cacertcontents, page_info, header_level) + print("
"..html.html_escape(view.value.cacertcontents.value).."
") + htmlviewfunctions.displaysectionend(header_level) + elseif viewlibrary and viewlibrary.dispatch_component then if viewlibrary.check_permission("putcacert") then viewlibrary.dispatch_component("putcacert") end @@ -38,9 +39,14 @@ if view.value.version and view.value.version.errtxt and viewlibrary.check_permis viewlibrary.dispatch_component("generatecacert") end end -end %> -<% if viewlibrary.check_permission("downloadcacert") then %> -

Download CA Cert

-<%= html.link{value="downloadcacert?viewtype=stream&certtype=pem", label="Download PEM"} %>
-<%= html.link{value="downloadcacert?viewtype=stream&certtype=der", label="Download DER"} %>
-<% end %> +end +%> + +<% +if viewlibrary.check_permission("downloadcacert") then + htmlviewfunctions.displaysectionstart(cfe({label="Download CA Cert"}), page_info, header_level) + htmlviewfunctions.displayitem(cfe({type="link", value={certtype=cfe({type="hidden", value="pem"}), viewtype=cfe({type="hidden", value="stream"})}, label="", option="Download PEM", action="downloadcacert"}), page_info, -1) + htmlviewfunctions.displayitem(cfe({type="link", value={certtype=cfe({type="hidden", value="der"}), viewtype=cfe({type="hidden", value="stream"})}, label="", option="Download DER", action="downloadcacert"}), page_info, -1) + htmlviewfunctions.displaysectionend(header_level) +end +%> diff --git a/openssl-viewcert-html.lsp b/openssl-viewcert-html.lsp index dcfb7d6..0774c4e 100644 --- a/openssl-viewcert-html.lsp +++ b/openssl-viewcert-html.lsp @@ -1,5 +1,7 @@ -<% local view, viewlibrary = ... %> +<% local view, viewlibrary, page_info, session = ... %> +<% htmlviewfunctions = require("htmlviewfunctions") %> <% html = require("acf.html") %> -

Certificate Details

+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<%= html.html_escape(view.value.value) %>
+<% htmlviewfunctions.displaysectionend(header_level) %> diff --git a/openssl-viewrequest-html.lsp b/openssl-viewrequest-html.lsp index a4e6440..0774c4e 100644 --- a/openssl-viewrequest-html.lsp +++ b/openssl-viewrequest-html.lsp @@ -1,5 +1,7 @@ -<% local view, viewlibrary = ... %> +<% local view, viewlibrary, page_info, session = ... %> +<% htmlviewfunctions = require("htmlviewfunctions") %> <% html = require("acf.html") %> -

Request Details

+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<%= html.html_escape(view.value.value) %>
+<% htmlviewfunctions.displaysectionend(header_level) %> -- cgit v1.2.3