2 * Copyright (c) 2011-2014, JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 namespace WebProvisioning
38 public static int main(string[] args)
41 int force_flat_file_store = 0;
42 bool bad_switch = false;
43 for (arg_index = 1; arg_index < args.length; arg_index++) {
44 string arg = args[arg_index];
45 unichar c = arg.get_char();
47 arg = arg.next_char();
51 force_flat_file_store = 1;
58 break; // arg is not a switch; presume it's the file
61 if (bad_switch || (arg_index != args.length - 1))
63 stdout.printf(_("Usage %s [-f] WEB_PROVISIONING_FILE\n -f: add identities to flat file store.\n"), args[0]);
66 string webp_file = args[arg_index];
68 if (!FileUtils.test(webp_file, FileTest.EXISTS | FileTest.IS_REGULAR))
70 stdout.printf(_("%s does not exist\n"), webp_file);
74 var webp = new Parser(webp_file);
77 foreach (IdCard card in cards)
80 string[] rules_patterns = {};
81 string[] rules_always_confirm = {};
83 /* use temp arrays to workaround centos array property bug */
84 var rules = card.rules;
85 var services = card.services;
89 rules_patterns = new string[rules.length];
90 rules_always_confirm = new string[rules.length];
91 foreach (Rule r in rules)
93 rules_patterns[i] = r.pattern;
94 rules_always_confirm[i] = r.always_confirm;
99 Moonshot.install_id_card(card.display_name,
104 rules_always_confirm,
106 card.trust_anchor.ca_cert,
107 card.trust_anchor.subject,
108 card.trust_anchor.subject_alt,
109 card.trust_anchor.server_cert,
110 force_flat_file_store,
115 stderr.printf("Error: %s", error.message);