1
2
3
4
5
6
7
8 """
9 Implements the the arcgui certificate information window.
10 """
11
12
13
14
15 import wx
16
17
18
19
20
21
22
23
24 import arc
25
26 EVT_CERTINFO_CLOSE_TYPE = wx.NewEventType()
27 EVT_CERTINFO_CLOSE = wx.PyEventBinder(EVT_CERTINFO_CLOSE_TYPE, 1)
28
30 """
31 Event sent by worker threads to update progress.
32 """
34 wx.PyCommandEvent.__init__(self, etype, eid)
35
38
39 kwds["style"] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.STAY_ON_TOP|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.CLIP_CHILDREN
40 wx.Frame.__init__(self, *args, **kwds)
41 self.panel_2 = wx.Panel(self, -1)
42 self.notebook_1 = wx.Notebook(self.panel_2, -1, style=0)
43 self.certPane = wx.Panel(self.notebook_1, -1)
44 self.dnLabel = wx.StaticText(self.certPane, -1, "DN")
45 self.dnText = wx.TextCtrl(self.certPane, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_LINEWRAP)
46 self.notBeforeLabel = wx.StaticText(self.certPane, -1, "Not before")
47 self.notBeforeText = wx.TextCtrl(self.certPane, -1, "")
48 self.notAfterLabel = wx.StaticText(self.certPane, -1, "Not after")
49 self.notAfterText = wx.TextCtrl(self.certPane, -1, "")
50 self.proxyPane = wx.Panel(self.notebook_1, -1)
51 self.proxyRemainingLabel = wx.StaticText(self.proxyPane, -1, "Remaining")
52 self.proxyRemainingText = wx.TextCtrl(self.proxyPane, -1, "")
53 self.proxyNotBeforeLabel = wx.StaticText(self.proxyPane, -1, "Not before")
54 self.proxyNotBeforeText = wx.TextCtrl(self.proxyPane, -1, "")
55 self.proxyNotAfterLabel = wx.StaticText(self.proxyPane, -1, "Not after")
56 self.proxyNotAfterText = wx.TextCtrl(self.proxyPane, -1, "")
57 self.closeButton = wx.Button(self.panel_2, -1, "Close")
58
59 self.__set_properties()
60 self.__do_layout()
61
62 self.Bind(wx.EVT_BUTTON, self.onClose, self.closeButton)
63
64
65 self.__initWindow()
66
68
69 self.SetTitle("Certificate information")
70 self.SetSize((432, 324))
71 self.dnLabel.SetMinSize((120, -1))
72 self.dnText.SetMinSize((-1, 54))
73 self.notBeforeLabel.SetMinSize((120, -1))
74 self.notBeforeText.SetMinSize((-1, 27))
75 self.notAfterLabel.SetMinSize((120, -1))
76 self.notAfterText.SetMinSize((-1, 27))
77 self.proxyRemainingLabel.SetMinSize((120, -1))
78 self.proxyRemainingText.SetMinSize((-1, 27))
79 self.proxyNotBeforeLabel.SetMinSize((120, -1))
80 self.proxyNotBeforeText.SetMinSize((-1, 27))
81 self.proxyNotAfterLabel.SetMinSize((120, -1))
82 self.proxyNotAfterText.SetMinSize((-1, 27))
83 self.notebook_1.SetMinSize((422, 272))
84
85
87
88 sizer_20 = wx.BoxSizer(wx.VERTICAL)
89 sizer_21 = wx.BoxSizer(wx.VERTICAL)
90 sizer_22 = wx.BoxSizer(wx.HORIZONTAL)
91 sizer_23_copy = wx.BoxSizer(wx.VERTICAL)
92 sizer_27_copy = wx.BoxSizer(wx.HORIZONTAL)
93 sizer_26_copy = wx.BoxSizer(wx.HORIZONTAL)
94 sizer_24_copy = wx.BoxSizer(wx.HORIZONTAL)
95 sizer_23 = wx.BoxSizer(wx.VERTICAL)
96 sizer_27 = wx.BoxSizer(wx.HORIZONTAL)
97 sizer_26 = wx.BoxSizer(wx.HORIZONTAL)
98 sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
99 sizer_24.Add(self.dnLabel, 0, 0, 0)
100 sizer_24.Add(self.dnText, 1, wx.EXPAND, 0)
101 sizer_23.Add(sizer_24, 0, wx.ALL|wx.EXPAND, 4)
102 sizer_26.Add(self.notBeforeLabel, 0, wx.ALIGN_CENTER_VERTICAL, 0)
103 sizer_26.Add(self.notBeforeText, 1, wx.EXPAND, 0)
104 sizer_23.Add(sizer_26, 0, wx.ALL|wx.EXPAND, 4)
105 sizer_27.Add(self.notAfterLabel, 0, wx.ALIGN_CENTER_VERTICAL, 0)
106 sizer_27.Add(self.notAfterText, 1, wx.EXPAND, 0)
107 sizer_23.Add(sizer_27, 0, wx.ALL|wx.EXPAND, 4)
108 self.certPane.SetSizer(sizer_23)
109 sizer_24_copy.Add(self.proxyRemainingLabel, 0, wx.ALIGN_CENTER_VERTICAL, 0)
110 sizer_24_copy.Add(self.proxyRemainingText, 1, wx.EXPAND, 0)
111 sizer_23_copy.Add(sizer_24_copy, 0, wx.ALL|wx.EXPAND, 4)
112 sizer_26_copy.Add(self.proxyNotBeforeLabel, 0, wx.ALIGN_CENTER_VERTICAL, 0)
113 sizer_26_copy.Add(self.proxyNotBeforeText, 1, wx.EXPAND, 0)
114 sizer_23_copy.Add(sizer_26_copy, 0, wx.ALL|wx.EXPAND, 4)
115 sizer_27_copy.Add(self.proxyNotAfterLabel, 0, wx.ALIGN_CENTER_VERTICAL, 0)
116 sizer_27_copy.Add(self.proxyNotAfterText, 1, wx.EXPAND, 0)
117 sizer_23_copy.Add(sizer_27_copy, 0, wx.ALL|wx.EXPAND, 4)
118 self.proxyPane.SetSizer(sizer_23_copy)
119 self.notebook_1.AddPage(self.certPane, "Certificate")
120 self.notebook_1.AddPage(self.proxyPane, "Proxy")
121 sizer_21.Add(self.notebook_1, 1, wx.ALL|wx.EXPAND, 5)
122 sizer_22.Add(self.closeButton, 0, 0, 0)
123 sizer_21.Add(sizer_22, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
124 self.panel_2.SetSizer(sizer_21)
125 sizer_20.Add(self.panel_2, 1, wx.EXPAND, 0)
126 self.SetSizer(sizer_20)
127 self.Layout()
128 self.Centre()
129
130
132 """
133 Custom window initialisation routine. Binds EVT_CLOSE to
134 onCloseWindow and initalises class variables.
135 """
136 self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
137 self.__userConfig = None
138
140 """
141 Handles a window close event notifying parent window that
142 the window is destroyed/closed.
143 """
144 evt = CertInfoCloseEvent(EVT_CERTINFO_CLOSE_TYPE, -1)
145 wx.PostEvent(self.GetParent(), evt)
146 self.Destroy()
147
149 """
150 Event method for handling the close button.
151 """
152 self.Close()
153
155 """
156 Handles the assignment of the userConfig property. Fills the
157 text boxes with relevant information
158 """
159 self.__userConfig = userConfig
160
161
162
163 proxyPath = str(self.__userConfig.ProxyPath())
164 userCertPath = str(self.__userConfig.CertificatePath())
165 userKeyPath = str(self.__userConfig.KeyPath())
166
167
168
169 credential = arc.Credential(userCertPath, "", "", "")
170 self.dnText.SetValue(credential.GetDN())
171 self.notBeforeText.SetValue(str(credential.GetStartTime()))
172 self.notAfterText.SetValue(str(credential.GetEndTime()))
173
174
175
176 credential = arc.Credential(proxyPath, "", "", "")
177 self.proxyNotBeforeText.SetValue(str(credential.GetStartTime()))
178 self.proxyNotAfterText.SetValue(str(credential.GetEndTime()))
179 self.proxyRemainingText.SetValue(str(credential.GetEndTime()-arc.Time()))
180
182 """
183 Returns the current value of the userConfig property.
184 """
185 return self.__userConfig
186
187 userConfig = property(getUserConfig, setUserConfig)
188
189
190