When prompting for identity, show requesting service
[moonshot-ui.git] / src / moonshot-webp-parser.vala
1 using Moonshot;
2
3 namespace WebProvisioning
4
5
6
7   public static int main (string[] args)
8   {
9     if (args.length < 2)
10     {
11       error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
12     }
13     
14     if (!FileUtils.test (args[1], FileTest.EXISTS | FileTest.IS_REGULAR))
15     {
16       error ("%s does not exist", args[1]);
17     }
18     
19     var webp = new Parser (args[1]);
20     webp.parse();
21     
22     foreach (IdCard card in cards)
23     {
24       Moonshot.Error error;
25       string[] rules_patterns = {};
26       string[] rules_always_confirm = {};
27         
28       if (card.rules.length > 0)
29       {
30         int i = 0;
31         rules_patterns = new string[card.rules.length];
32         rules_always_confirm = new string[card.rules.length];
33         foreach (Rule r in card.rules)
34         {
35           rules_patterns[i] = r.pattern;
36           rules_always_confirm[i] = r.always_confirm;
37           i++;
38         }
39       }
40
41       Moonshot.install_id_card (card.display_name,
42                                 card.username,
43                                 card.password,
44                                 card.issuer,
45                                 rules_patterns,
46                                 rules_always_confirm,
47                                 card.services,
48                                 card.trust_anchor.ca_cert,
49                                 card.trust_anchor.subject,
50                                 card.trust_anchor.subject_alt,
51                                 card.trust_anchor.server_cert,
52                                 out error);
53
54       if (error != null)
55       {
56         stderr.printf ("Error: %s", error.message);
57         continue;
58       }
59     }
60     
61     return 0;
62   }
63 }