Comparison

mod_seclabels/mod_seclabels.lua @ 449:08ffbbdafeea

mod_seclabels: Fetch catalog from config.
author Kim Alvefur <zash@zash.se>
date Wed, 05 Oct 2011 21:00:12 +0200
parent 266:e7296274f48c
child 450:fb152d4af082
comparison
equal deleted inserted replaced
448:3bf6f102f1cc 449:08ffbbdafeea
9 local stanza = event.stanza; 9 local stanza = event.stanza;
10 stanza:tag('feature', {var=xmlns_label}):up(); 10 stanza:tag('feature', {var=xmlns_label}):up();
11 stanza:tag('feature', {var=xmlns_label_catalog}):up(); 11 stanza:tag('feature', {var=xmlns_label_catalog}):up();
12 end); 12 end);
13 13
14 local labels = { 14 local default_labels = {
15 Classified = { 15 Classified = {
16 SECRET = { color = "black", bgcolor = "aqua", label = "THISISSECRET" }; 16 SECRET = { color = "black", bgcolor = "aqua", label = "THISISSECRET" };
17 PUBLIC = { label = "THISISPUBLIC" }; 17 PUBLIC = { label = "THISISPUBLIC" };
18 }; 18 };
19 }; 19 };
20 local catalog_name, catalog_desc, labels;
21 function get_conf()
22 catalog_name = module:get_option_string("security_catalog_name", "Default");
23 catalog_desc = module:get_option_string("security_catalog_desc", "My labels");
24 labels = module:get_option("security_labels", default_labels);
25 end
26 module:hook("config-reloaded",get_conf);
27 get_conf();
20 28
21 module:hook("iq/self/"..xmlns_label_catalog..":catalog", function (request) 29 module:hook("iq/self/"..xmlns_label_catalog..":catalog", function (request)
22 local catalog_request = request.stanza.tags[1]; 30 local catalog_request = request.stanza.tags[1];
23 local reply = st.reply(request.stanza) 31 local reply = st.reply(request.stanza)
24 :tag("catalog", { 32 :tag("catalog", {
25 xmlns = xmlns_label_catalog, 33 xmlns = xmlns_label_catalog,
26 to = catalog_request.attr.to, 34 to = catalog_request.attr.to,
27 name = "Default", 35 name = catalog_name,
28 desc = "My labels" 36 desc = catalog_desc
29 }); 37 });
30 38
31 local function add_labels(catalog, labels, selector) 39 local function add_labels(catalog, labels, selector)
32 for name, value in pairs(labels) do 40 for name, value in pairs(labels) do
33 if value.label then 41 if value.label then