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 | ||
21 | package base.jdbs.ui.panel; | |
22 | ||
23 | import java.awt.BorderLayout; | |
24 | import java.awt.GridLayout; | |
25 | import java.awt.event.ActionEvent; | |
26 | import java.awt.event.ActionListener; | |
27 | import java.io.File; | |
28 | ||
29 | import javax.swing.JButton; | |
30 | import javax.swing.JCheckBox; | |
31 | import javax.swing.JComboBox; | |
32 | import javax.swing.JLabel; | |
33 | import javax.swing.JPanel; | |
34 | import javax.swing.JTextField; | |
35 | import javax.swing.border.TitledBorder; | |
36 | ||
37 | import org.apache.log4j.Logger; | |
38 | ||
39 | import base.jdbs.ConfigurationManager; | |
40 | import base.jdbs.SecurityLevel; | |
41 | ||
42 | 0 | @SuppressWarnings("serial") |
43 | 0 | public class SecurityConfigurationPanel extends JPanel { |
44 | 0 | |
45 | 0 | private static final transient Logger logger = Logger |
46 | .getLogger(SecurityConfigurationPanel.class.getName()); | |
47 | ||
48 | private JPanel keyStoreLocationPanel; | |
49 | ||
50 | private JTextField keyStoreLocationTextField; | |
51 | 0 | |
52 | private JPanel buttonPanel; | |
53 | ||
54 | private JButton keyStoreLoadButton; | |
55 | ||
56 | 0 | private JButton keyStoreCreateButton; |
57 | 0 | |
58 | 0 | private JPanel authenticatePeerDownloadPanel; |
59 | ||
60 | private JCheckBox authenticatePeerDownloadCheckBox; | |
61 | 0 | |
62 | 0 | private JPanel securityLevelPanel; |
63 | 0 | |
64 | 0 | private JComboBox securityLevelComboBox; |
65 | 0 | |
66 | 0 | public SecurityConfigurationPanel() { |
67 | 0 | initialize(); |
68 | 0 | } |
69 | ||
70 | protected void initialize() { | |
71 | 0 | this.setBorder(new TitledBorder("Security Configuration Parameters")); |
72 | 0 | this.setLayout(new GridLayout(3, 1)); |
73 | 0 | this.add(this.getKeyStoreLocationPanel()); |
74 | 0 | this.add(this.getSecurityLevelPanel()); |
75 | 0 | this.add(this.getAuthenticatePeerDownloadPanel()); |
76 | 0 | } |
77 | 0 | |
78 | /** | |
79 | * @return the keyStoreLocationPanel | |
80 | 0 | */ |
81 | protected JPanel getKeyStoreLocationPanel() { | |
82 | 0 | if (this.keyStoreLocationPanel == null) { |
83 | 0 | this.keyStoreLocationPanel = new JPanel(); |
84 | 0 | this.keyStoreLocationPanel.setBorder(new TitledBorder( |
85 | "Asymetric Key Ring Location")); | |
86 | 0 | this.keyStoreLocationPanel.setLayout(new BorderLayout()); |
87 | 0 | this.keyStoreLocationPanel.add(this.getKeyStoreLocationTextField(), |
88 | 0 | BorderLayout.CENTER); |
89 | 0 | this.keyStoreLocationPanel.add(this.getButtonPanel(), |
90 | 0 | BorderLayout.SOUTH); |
91 | 0 | |
92 | 0 | } |
93 | 0 | return keyStoreLocationPanel; |
94 | 0 | } |
95 | ||
96 | /** | |
97 | * @return the buttonPanel | |
98 | */ | |
99 | protected JPanel getButtonPanel() { | |
100 | 0 | if (this.buttonPanel == null) { |
101 | 0 | this.buttonPanel = new JPanel(); |
102 | 0 | this.buttonPanel.setLayout(new GridLayout(1, 4)); |
103 | 0 | this.buttonPanel.add(new JLabel()); |
104 | 0 | this.buttonPanel.add(this.getKeyStoreLoadButton()); |
105 | 0 | this.buttonPanel.add(this.getKeyStoreCreateButton()); |
106 | 0 | this.buttonPanel.add(new JLabel()); |
107 | } | |
108 | 0 | return buttonPanel; |
109 | } | |
110 | ||
111 | /** | |
112 | * @return the keyStoreLoadButton | |
113 | */ | |
114 | protected JButton getKeyStoreLoadButton() { | |
115 | 0 | if (this.keyStoreLoadButton == null) { |
116 | 0 | this.keyStoreLoadButton = new JButton("Change"); |
117 | 0 | this.keyStoreLoadButton |
118 | 0 | .addActionListener(new ActionListener() { |
119 | ||
120 | public void actionPerformed(ActionEvent arg0) { | |
121 | javax.swing.JFileChooser chooser = new javax.swing.JFileChooser(); | |
122 | chooser | |
123 | .setDialogTitle("Select the keyring file to be loaded..."); | |
124 | chooser | |
125 | 0 | .setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY); |
126 | 0 | chooser.setApproveButtonText("Select"); |
127 | 0 | if (chooser.showOpenDialog(null) == javax.swing.JFileChooser.APPROVE_OPTION) { |
128 | 0 | ConfigurationManager.getInstance() |
129 | .setKeyRingLocation( | |
130 | 0 | new File(chooser |
131 | .getSelectedFile() | |
132 | .getAbsolutePath())); | |
133 | getKeyStoreLocationTextField().setText( | |
134 | chooser.getSelectedFile() | |
135 | .getAbsolutePath()); | |
136 | } | |
137 | 0 | } |
138 | 0 | |
139 | 0 | }); |
140 | 0 | } |
141 | 0 | return keyStoreLoadButton; |
142 | 0 | } |
143 | ||
144 | 0 | /** |
145 | * @return the keyStoreCreateButton | |
146 | 0 | */ |
147 | protected JButton getKeyStoreCreateButton() { | |
148 | 0 | if (this.keyStoreCreateButton == null) { |
149 | 0 | this.keyStoreCreateButton = new JButton("Create"); |
150 | 0 | this.keyStoreCreateButton |
151 | .addActionListener(new ActionListener() { | |
152 | ||
153 | 0 | public void actionPerformed(ActionEvent arg0) { |
154 | 0 | |
155 | 0 | |
156 | 0 | } |
157 | 0 | |
158 | }); | |
159 | } | |
160 | 0 | return keyStoreLoadButton; |
161 | } | |
162 | ||
163 | /** | |
164 | * @return the keyStoreLocationTextField | |
165 | */ | |
166 | protected JTextField getKeyStoreLocationTextField() { | |
167 | 0 | if (this.keyStoreLocationTextField == null) { |
168 | 0 | this.keyStoreLocationTextField = new JTextField(); |
169 | 0 | this.keyStoreLocationTextField.setEditable(false); |
170 | 0 | this.keyStoreLocationTextField.setText(!("" + ConfigurationManager |
171 | 0 | .getInstance().getKeyRingLocation()) |
172 | .equalsIgnoreCase("null") ? "" | |
173 | + ConfigurationManager.getInstance().getKeyRingLocation() | |
174 | : "A key ring in not yet defined!"); | |
175 | } | |
176 | 0 | return keyStoreLocationTextField; |
177 | } | |
178 | 0 | |
179 | /** | |
180 | * @return the securityLevelComboBox | |
181 | */ | |
182 | protected JComboBox getSecurityLevelComboBox() { | |
183 | 0 | if (this.securityLevelComboBox == null) { |
184 | 0 | this.securityLevelComboBox = new JComboBox(); |
185 | 0 | for (int i = 0; i < SecurityLevel.level.length; i++) { |
186 | 0 | this.securityLevelComboBox.addItem(SecurityLevel.level[i]); |
187 | 0 | if (ConfigurationManager.getInstance() |
188 | 0 | .getDefaultBackupSecurityLevel().toString() |
189 | 0 | .equalsIgnoreCase(SecurityLevel.level[i])) |
190 | 0 | this.securityLevelComboBox |
191 | 0 | .setSelectedItem(SecurityLevel.level[i]); |
192 | } | |
193 | 0 | this.securityLevelComboBox |
194 | .setToolTipText("If private each created backuo will be encrypted and signed, will be not otherwise."); | |
195 | } | |
196 | 0 | return securityLevelComboBox; |
197 | } | |
198 | ||
199 | /** | |
200 | * @return the securityLevelPanel | |
201 | */ | |
202 | protected JPanel getSecurityLevelPanel() { | |
203 | 0 | if (this.securityLevelPanel == null) { |
204 | 0 | this.securityLevelPanel = new JPanel(); |
205 | 0 | this.securityLevelPanel.setBorder(new TitledBorder( |
206 | "Backup Security Level")); | |
207 | 0 | this.securityLevelPanel.setLayout(new BorderLayout()); |
208 | 0 | this.securityLevelPanel.add(this.getSecurityLevelComboBox(), |
209 | BorderLayout.CENTER); | |
210 | ||
211 | } | |
212 | 0 | return securityLevelPanel; |
213 | } | |
214 | ||
215 | /** | |
216 | * @return Returns the authenticatePeerDownloadCheckBox. | |
217 | */ | |
218 | protected JCheckBox getAuthenticatePeerDownloadCheckBox() { | |
219 | 0 | if (this.authenticatePeerDownloadCheckBox == null) { |
220 | 0 | this.authenticatePeerDownloadCheckBox = new JCheckBox(); |
221 | 0 | this.authenticatePeerDownloadCheckBox |
222 | .setToolTipText("Enables an X509Certificate check between the peer that is trying to download a backup and its owner."); | |
223 | 0 | this.authenticatePeerDownloadCheckBox |
224 | .setSelected(ConfigurationManager.getInstance() | |
225 | .isEnabledPeerDownloadAuthentication()); | |
226 | 0 | this.authenticatePeerDownloadCheckBox |
227 | .addActionListener(new ActionListener() { | |
228 | ||
229 | public void actionPerformed(ActionEvent arg0) { | |
230 | ConfigurationManager.getInstance() | |
231 | .setEnabledPeerDownloadAuthentication( | |
232 | authenticatePeerDownloadCheckBox | |
233 | .isSelected()); | |
234 | ||
235 | } | |
236 | }); | |
237 | } | |
238 | 0 | return authenticatePeerDownloadCheckBox; |
239 | } | |
240 | ||
241 | /** | |
242 | * @return Returns the authenticatePeerDownloadPanel. | |
243 | */ | |
244 | protected JPanel getAuthenticatePeerDownloadPanel() { | |
245 | 0 | if (this.authenticatePeerDownloadPanel == null) { |
246 | 0 | this.authenticatePeerDownloadPanel = new JPanel(); |
247 | 0 | this.authenticatePeerDownloadPanel.setBorder(new TitledBorder( |
248 | "Download Authentication")); | |
249 | 0 | this.authenticatePeerDownloadPanel.setLayout(new BorderLayout()); |
250 | 0 | this.authenticatePeerDownloadPanel |
251 | .add(this.getAuthenticatePeerDownloadCheckBox(), | |
252 | BorderLayout.CENTER); | |
253 | } | |
254 | 0 | return authenticatePeerDownloadPanel; |
255 | } | |
256 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |