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 private Entry trust_anchor_entry;
40 public bool complete = false;
42 public TrustAnchorDialog(IdCard idcard, Window parent)
44 this.set_title(_("Trust Anchor"));
46 this.set_transient_for(parent);
47 this.modify_bg(StateType.NORMAL, white);
49 this.add_buttons(_("Confirm"), ResponseType.OK,
50 _("Cancel"), ResponseType.CANCEL);
52 this.set_default_response(ResponseType.OK);
54 var content_area = this.get_content_area();
55 ((Box) content_area).set_spacing(12);
56 content_area.modify_bg(StateType.NORMAL, white);
58 Label dialog_label = new Label("");
59 dialog_label.set_alignment(0, 0);
61 string label_markup = _("<span font-weight='heavy'>You are using this identity for the first time with the following trust anchor:</span>");
63 dialog_label.set_markup(label_markup);
64 dialog_label.set_line_wrap(true);
65 dialog_label.set_width_chars(60);
67 var user_label = new Label(_("Username: ") + idcard.username);
68 user_label.set_alignment(0, 0.5f);
70 var realm_label = new Label(_("Realm: ") + idcard.issuer);
71 realm_label.set_alignment(0, 0.5f);
73 Label confirm_label = new Label(_("Please confirm that this is the correct trust anchor."));
74 confirm_label.set_alignment(0, 0.5f);
76 var trust_anchor_display = make_ta_fingerprint_widget(idcard.trust_anchor);
78 var vbox = new VBox(false, 0);
79 vbox.set_border_width(6);
80 vbox.pack_start(dialog_label, true, true, 12);
81 vbox.pack_start(user_label, true, true, 2);
82 vbox.pack_start(realm_label, true, true, 2);
83 vbox.pack_start(trust_anchor_display, true, true, 0);
84 vbox.pack_start(confirm_label, true, true, 12);
86 ((Container) content_area).add(vbox);
88 this.set_border_width(6);
89 this.set_resizable(false);
91 this.response.connect(on_response);
96 private void on_response(Dialog source, int response_id)
98 switch (response_id) {
102 case ResponseType.CANCEL: