2 * Copyright (c) 2011-2016, 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 class TrustAnchorDialog : Dialog
36 private static Gdk.Color white = make_color(65535, 65535, 65535);
38 public bool complete = false;
40 public TrustAnchorDialog(IdCard idcard, Window parent)
42 this.set_title(_("Trust Anchor"));
44 this.set_transient_for(parent);
45 this.modify_bg(StateType.NORMAL, white);
47 this.add_buttons(_("Cancel"), ResponseType.CANCEL,
48 _("Confirm"), ResponseType.OK);
50 this.set_default_response(ResponseType.OK);
52 var content_area = this.get_content_area();
53 ((Box) content_area).set_spacing(12);
54 content_area.modify_bg(StateType.NORMAL, white);
56 Label dialog_label = new Label("");
57 dialog_label.set_alignment(0, 0);
59 string label_markup = "<span font-weight='heavy'>" + _("You are using this identity for the first time with the following trust anchor:") + "</span>";
61 dialog_label.set_markup(label_markup);
62 dialog_label.set_line_wrap(true);
63 dialog_label.set_width_chars(60);
65 var user_label = new Label(_("Username: ") + idcard.username);
66 user_label.set_alignment(0, 0.5f);
68 var realm_label = new Label(_("Realm: ") + idcard.issuer);
69 realm_label.set_alignment(0, 0.5f);
71 Label confirm_label = new Label(_("Please confirm that this is the correct trust anchor."));
72 confirm_label.set_alignment(0, 0.5f);
74 var trust_anchor_display = make_ta_fingerprint_widget(idcard.trust_anchor);
76 var vbox = new VBox(false, 0);
77 vbox.set_border_width(6);
78 vbox.pack_start(dialog_label, true, true, 12);
79 vbox.pack_start(user_label, true, true, 2);
80 vbox.pack_start(realm_label, true, true, 2);
81 vbox.pack_start(trust_anchor_display, true, true, 0);
82 vbox.pack_start(confirm_label, true, true, 12);
84 ((Container) content_area).add(vbox);
86 this.set_border_width(6);
87 this.set_resizable(false);
89 this.response.connect(on_response);
94 private void on_response(Dialog source, int response_id)
96 switch (response_id) {
100 case ResponseType.CANCEL: