Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | package ui.panel; | |
21 | ||
22 | import java.awt.BorderLayout; | |
23 | import java.awt.GridLayout; | |
24 | import java.awt.event.ActionEvent; | |
25 | import java.awt.event.ActionListener; | |
26 | import java.util.Date; | |
27 | import java.util.GregorianCalendar; | |
28 | ||
29 | import javax.swing.JCheckBox; | |
30 | import javax.swing.JPanel; | |
31 | import javax.swing.JTextArea; | |
32 | import javax.swing.border.TitledBorder; | |
33 | ||
34 | import ui.Messages; | |
35 | import base.ConfigurationManager; | |
36 | ||
37 | import com.toedter.calendar.JTimeChooser; | |
38 | ||
39 | 0 | @SuppressWarnings("serial") //$NON-NLS-1$ |
40 | 0 | public class SecurityConfigurationPanel extends JPanel { |
41 | ||
42 | private JPanel passwordProtectPanel; | |
43 | 0 | |
44 | 0 | private JCheckBox passwordProtectCheckBox; |
45 | 0 | |
46 | private JPanel automaticPasswordProtectPanel; | |
47 | ||
48 | private JTimeChooser automaticPasswordProtectTimeChooser; | |
49 | ||
50 | private JCheckBox automaticPasswordProtectCheckBox; | |
51 | ||
52 | private JPanel symmetricCryptographyPanel; | |
53 | private JTextArea symmetricCryptographyTextArea; | |
54 | ||
55 | private JPanel asymmetricCryptographyPanel; | |
56 | private JTextArea asymmetricCryptographyPublicKeyTextArea; | |
57 | private JTextArea asymmetricCryptographyPrivateKeyTextArea; | |
58 | ||
59 | 0 | |
60 | 0 | public SecurityConfigurationPanel() { |
61 | 0 | initialize(); |
62 | 0 | } |
63 | 0 | |
64 | 0 | protected void initialize() { |
65 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.securityconfiguration")); //$NON-NLS-1$ |
66 | 0 | this.setBorder(titledBorder); |
67 | 0 | this.setLayout(new GridLayout(3, 1)); |
68 | 0 | this.add(getPasswordProtectPanel(), null); |
69 | 0 | this.add(getAsymmetricCryptographyPanel(), null); |
70 | 0 | this.add(getSymmetricCryptographyPanel(), null); |
71 | 0 | } |
72 | 0 | |
73 | /** | |
74 | * @return Returns the passwordProtectPanel. | |
75 | */ | |
76 | 0 | protected JPanel getPasswordProtectPanel() { |
77 | 0 | if (passwordProtectPanel == null) { |
78 | 0 | passwordProtectPanel = new JPanel(); |
79 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("common.passwordprotect")); //$NON-NLS-1$ |
80 | 0 | passwordProtectPanel.setBorder(titledBorder); |
81 | 0 | passwordProtectPanel.setLayout(new BorderLayout()); |
82 | 0 | passwordProtectPanel.add(getAutomaticPasswordProtectPanel(), |
83 | 0 | BorderLayout.CENTER); |
84 | 0 | passwordProtectPanel.add(getPasswordProtectCheckBox(), |
85 | 0 | BorderLayout.WEST); |
86 | 0 | |
87 | 0 | } |
88 | 0 | return passwordProtectPanel; |
89 | 0 | } |
90 | ||
91 | /** | |
92 | * @return Returns the passwordProtectCheckBox. | |
93 | */ | |
94 | 0 | protected JCheckBox getPasswordProtectCheckBox() { |
95 | 0 | if (passwordProtectCheckBox == null) { |
96 | 0 | passwordProtectCheckBox = new JCheckBox(); |
97 | 0 | passwordProtectCheckBox |
98 | 0 | .setToolTipText(Messages.getString("panel.securityconfigurationpanel.message1")); //$NON-NLS-1$ |
99 | 0 | passwordProtectCheckBox.setSelected(ConfigurationManager |
100 | 0 | .getInstance().isPasswordProtect()); |
101 | 0 | passwordProtectCheckBox.addActionListener(new ActionListener() { |
102 | 0 | public void actionPerformed(ActionEvent arg0) { |
103 | ConfigurationManager.getInstance().setPasswordProtect( | |
104 | passwordProtectCheckBox.isSelected()); | |
105 | } | |
106 | }); | |
107 | 0 | } |
108 | 0 | return passwordProtectCheckBox; |
109 | 0 | } |
110 | ||
111 | /** | |
112 | * @return Returns the automaticPasswordProtectCheckBox. | |
113 | */ | |
114 | 0 | protected JCheckBox getAutomaticPasswordProtectCheckBox() { |
115 | 0 | if (automaticPasswordProtectCheckBox == null) { |
116 | 0 | automaticPasswordProtectCheckBox = new JCheckBox(); |
117 | 0 | automaticPasswordProtectCheckBox.setSelected(ConfigurationManager |
118 | 0 | .getInstance().isAutomaticPasswordProtected()); |
119 | 0 | automaticPasswordProtectCheckBox |
120 | 0 | .addActionListener(new ActionListener() { |
121 | 0 | public void actionPerformed(ActionEvent arg0) { |
122 | ConfigurationManager | |
123 | .getInstance() | |
124 | .setAutomaticPasswordProtect( | |
125 | getAutomaticPasswordProtectCheckBox() | |
126 | .isSelected()); | |
127 | ConfigurationManager | |
128 | .getInstance() | |
129 | .setLogoutScheduleRate( | |
130 | (int) (((Date) getAutomaticPasswordProtectTimeChooser() | |
131 | .getValue()).getTime() / 1000)); | |
132 | ||
133 | } | |
134 | ||
135 | }); | |
136 | ||
137 | 0 | } |
138 | 0 | return automaticPasswordProtectCheckBox; |
139 | 0 | } |
140 | ||
141 | /** | |
142 | * @return Returns the automaticPasswordProtectPanel. | |
143 | */ | |
144 | 0 | protected JPanel getAutomaticPasswordProtectPanel() { |
145 | 0 | if (automaticPasswordProtectPanel == null) { |
146 | 0 | automaticPasswordProtectPanel = new JPanel(); |
147 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("common.automaticprotection")); //$NON-NLS-1$ |
148 | 0 | automaticPasswordProtectPanel.setBorder(titledBorder); |
149 | 0 | automaticPasswordProtectPanel.setLayout(new BorderLayout()); |
150 | 0 | automaticPasswordProtectPanel.add( |
151 | 0 | getAutomaticPasswordProtectTimeChooser(), |
152 | 0 | BorderLayout.CENTER); |
153 | 0 | automaticPasswordProtectPanel.add( |
154 | 0 | getAutomaticPasswordProtectCheckBox(), BorderLayout.EAST); |
155 | 0 | } |
156 | 0 | return automaticPasswordProtectPanel; |
157 | 0 | } |
158 | ||
159 | /** | |
160 | * @return Returns the automaticPasswordProtectTimeChooser. | |
161 | */ | |
162 | 0 | protected JTimeChooser getAutomaticPasswordProtectTimeChooser() { |
163 | 0 | if (automaticPasswordProtectTimeChooser == null) { |
164 | 0 | automaticPasswordProtectTimeChooser = new JTimeChooser(); |
165 | 0 | GregorianCalendar gc = new GregorianCalendar(0, 0, 0, 0, 0, |
166 | 0 | ConfigurationManager.getInstance().getLogoutScheduleRate()); |
167 | 0 | automaticPasswordProtectTimeChooser.setValue(gc.getTime()); |
168 | 0 | |
169 | 0 | } |
170 | 0 | return automaticPasswordProtectTimeChooser; |
171 | 0 | } |
172 | ||
173 | /** | |
174 | * @return Returns the asymmetricCryptographyPanel. | |
175 | */ | |
176 | 0 | protected JPanel getAsymmetricCryptographyPanel() { |
177 | 0 | if (asymmetricCryptographyPanel == null) { |
178 | 0 | asymmetricCryptographyPanel = new JPanel(); |
179 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.common.asymmetriccryptographysettings")); //$NON-NLS-1$ |
180 | 0 | asymmetricCryptographyPanel.setBorder(titledBorder); |
181 | 0 | asymmetricCryptographyPanel.setLayout(new GridLayout(1,2)); |
182 | 0 | JPanel publicKeyPanel = new JPanel(); |
183 | 0 | publicKeyPanel.setLayout(new BorderLayout()); |
184 | 0 | publicKeyPanel.setBorder(new TitledBorder(Messages.getString("common.publickey"))); //$NON-NLS-1$ |
185 | 0 | publicKeyPanel.add(getAsymmetricCryptographyPublicKeyTextArea(),BorderLayout.CENTER); |
186 | 0 | |
187 | 0 | JPanel privateKeyPanel = new JPanel(); |
188 | 0 | privateKeyPanel.setLayout(new BorderLayout()); |
189 | 0 | privateKeyPanel.setBorder(new TitledBorder(Messages.getString("common.privatekey"))); //$NON-NLS-1$ |
190 | 0 | privateKeyPanel.add(getAsymmetricCryptographyPrivateKeyTextArea(),BorderLayout.CENTER); |
191 | 0 | |
192 | 0 | asymmetricCryptographyPanel.add(publicKeyPanel); |
193 | 0 | asymmetricCryptographyPanel.add(privateKeyPanel); |
194 | 0 | |
195 | 0 | } |
196 | 0 | return asymmetricCryptographyPanel; |
197 | 0 | } |
198 | ||
199 | /** | |
200 | * @return Returns the symmetricCryptographyPanel. | |
201 | */ | |
202 | 0 | protected JPanel getSymmetricCryptographyPanel() { |
203 | 0 | if (symmetricCryptographyPanel == null) { |
204 | 0 | symmetricCryptographyPanel = new JPanel(); |
205 | 0 | TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.common.symmetriccryptographysettings")); //$NON-NLS-1$ |
206 | 0 | symmetricCryptographyPanel.setBorder(titledBorder); |
207 | 0 | symmetricCryptographyPanel.setLayout(new GridLayout(1,2)); |
208 | 0 | symmetricCryptographyPanel.add(getSymmetricCryptographyTextArea()); |
209 | 0 | } |
210 | 0 | return symmetricCryptographyPanel; |
211 | 0 | } |
212 | ||
213 | /** | |
214 | * @return Returns the asymmetricCryptographyPrivateKeyTextArea. | |
215 | */ | |
216 | 0 | protected JTextArea getAsymmetricCryptographyPrivateKeyTextArea() { |
217 | 0 | if(asymmetricCryptographyPrivateKeyTextArea == null){ |
218 | 0 | asymmetricCryptographyPrivateKeyTextArea = new JTextArea(); |
219 | 0 | } |
220 | 0 | return asymmetricCryptographyPrivateKeyTextArea; |
221 | 0 | } |
222 | ||
223 | /** | |
224 | * @return Returns the asymmetricCryptographyPublicKeyTextArea. | |
225 | */ | |
226 | 0 | protected JTextArea getAsymmetricCryptographyPublicKeyTextArea() { |
227 | 0 | if(asymmetricCryptographyPublicKeyTextArea == null){ |
228 | 0 | asymmetricCryptographyPublicKeyTextArea = new JTextArea(); |
229 | 0 | } |
230 | 0 | return asymmetricCryptographyPublicKeyTextArea; |
231 | 0 | } |
232 | ||
233 | /** | |
234 | * @return Returns the symmetricCryptographyTextArea. | |
235 | */ | |
236 | 0 | protected JTextArea getSymmetricCryptographyTextArea() { |
237 | 0 | if(symmetricCryptographyTextArea == null){ |
238 | 0 | symmetricCryptographyTextArea = new JTextArea(); |
239 | 0 | } |
240 | 0 | return symmetricCryptographyTextArea; |
241 | 0 | } |
242 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |