1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.app.client.web.view;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.gwe.app.client.config.ClientConfig;
23 import org.gwe.utils.security.AccessControl;
24 import org.gwe.utils.security.KeyStore;
25 import org.gwe.utils.security.Realm;
26 import org.gwe.utils.security.RealmTestResult;
27 import org.gwe.utils.web.HtmlTable;
28 import org.gwe.utils.web.HtmlTableCell;
29 import org.gwe.utils.web.WebIcon;
30
31
32
33
34
35 public class HtmlKeysTable extends HtmlTable {
36
37 private static Map<RealmTestResult, WebIcon> STATUS_IMAGES = new HashMap<RealmTestResult, WebIcon>();
38
39 static {
40 STATUS_IMAGES.put(RealmTestResult.OK, WebIcon.STATUS_OK);
41 STATUS_IMAGES.put(RealmTestResult.ERROR, WebIcon.STATUS_ERROR);
42 STATUS_IMAGES.put(RealmTestResult.NO_SSH_REALM, WebIcon.STATUS_HELP);
43 STATUS_IMAGES.put(RealmTestResult.MISSING_TEST_HOST, WebIcon.STATUS_HELP);
44 STATUS_IMAGES.put(RealmTestResult.MISSING_ACCOUNT, WebIcon.STATUS_WARN);
45 STATUS_IMAGES.put(RealmTestResult.MISSING_PASSKEY, WebIcon.STATUS_WARN);
46 }
47
48 public HtmlKeysTable(ClientConfig config) {
49 super("User Name", "Authentication", "Domains", "Test Host", "");
50
51 KeyStore keys = config.getKeys();
52 for (AccessControl ac : keys.getAccessControls()) {
53 for (Realm realm : ac.getRealms()) {
54 HtmlTableCell status = new HtmlTableCell("Tested!", "", null, STATUS_IMAGES.get(realm.getTestResult()));
55 addRow(realm.getAccount().getUser(), getAuth(realm), realm.getDomain(), realm.getTestHost(), status);
56 }
57 }
58 }
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 private String getAuth(Realm realm) {
83 return missingAuth(realm) ? "< MISSING >" : "***********";
84 }
85
86 private boolean missingAuth(Realm realm) {
87 return realm.getAccount().missingPasskey();
88 }
89 }
90