Coverage details for base.jdbs.ui.panel.SecurityConfigurationPanel

LineHitsSource
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  
420@SuppressWarnings("serial")
430public class SecurityConfigurationPanel extends JPanel {
440 
450    private static final transient Logger logger = Logger
46             .getLogger(SecurityConfigurationPanel.class.getName());
47  
48     private JPanel keyStoreLocationPanel;
49  
50     private JTextField keyStoreLocationTextField;
510 
52     private JPanel buttonPanel;
53  
54     private JButton keyStoreLoadButton;
55     
560    private JButton keyStoreCreateButton;
570 
580    private JPanel authenticatePeerDownloadPanel;
59  
60     private JCheckBox authenticatePeerDownloadCheckBox;
610 
620    private JPanel securityLevelPanel;
630 
640    private JComboBox securityLevelComboBox;
650 
660    public SecurityConfigurationPanel() {
670        initialize();
680    }
69  
70     protected void initialize() {
710        this.setBorder(new TitledBorder("Security Configuration Parameters"));
720        this.setLayout(new GridLayout(3, 1));
730        this.add(this.getKeyStoreLocationPanel());
740        this.add(this.getSecurityLevelPanel());
750        this.add(this.getAuthenticatePeerDownloadPanel());
760    }
770 
78     /**
79      * @return the keyStoreLocationPanel
800     */
81     protected JPanel getKeyStoreLocationPanel() {
820        if (this.keyStoreLocationPanel == null) {
830            this.keyStoreLocationPanel = new JPanel();
840            this.keyStoreLocationPanel.setBorder(new TitledBorder(
85                     "Asymetric Key Ring Location"));
860            this.keyStoreLocationPanel.setLayout(new BorderLayout());
870            this.keyStoreLocationPanel.add(this.getKeyStoreLocationTextField(),
880                    BorderLayout.CENTER);
890            this.keyStoreLocationPanel.add(this.getButtonPanel(),
900                    BorderLayout.SOUTH);
910 
920        }
930        return keyStoreLocationPanel;
940    }
95  
96     /**
97      * @return the buttonPanel
98      */
99     protected JPanel getButtonPanel() {
1000        if (this.buttonPanel == null) {
1010            this.buttonPanel = new JPanel();
1020            this.buttonPanel.setLayout(new GridLayout(1, 4));
1030            this.buttonPanel.add(new JLabel());
1040            this.buttonPanel.add(this.getKeyStoreLoadButton());
1050            this.buttonPanel.add(this.getKeyStoreCreateButton());
1060            this.buttonPanel.add(new JLabel());
107         }
1080        return buttonPanel;
109     }
110  
111     /**
112      * @return the keyStoreLoadButton
113      */
114     protected JButton getKeyStoreLoadButton() {
1150        if (this.keyStoreLoadButton == null) {
1160            this.keyStoreLoadButton = new JButton("Change");
1170            this.keyStoreLoadButton
1180                    .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
1250                                    .setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
1260                            chooser.setApproveButtonText("Select");
1270                            if (chooser.showOpenDialog(null) == javax.swing.JFileChooser.APPROVE_OPTION) {
1280                                ConfigurationManager.getInstance()
129                                         .setKeyRingLocation(
1300                                                new File(chooser
131                                                         .getSelectedFile()
132                                                         .getAbsolutePath()));
133                                 getKeyStoreLocationTextField().setText(
134                                         chooser.getSelectedFile()
135                                                 .getAbsolutePath());
136                             }
1370                        }
1380 
1390                    });
1400        }
1410        return keyStoreLoadButton;
1420    }
143     
1440    /**
145      * @return the keyStoreCreateButton
1460     */
147     protected JButton getKeyStoreCreateButton() {
1480        if (this.keyStoreCreateButton == null) {
1490            this.keyStoreCreateButton = new JButton("Create");
1500            this.keyStoreCreateButton
151                     .addActionListener(new ActionListener() {
152  
1530                        public void actionPerformed(ActionEvent arg0) {
1540                            
1550                            
1560                        }
1570 
158                     });
159         }
1600        return keyStoreLoadButton;
161     }
162  
163     /**
164      * @return the keyStoreLocationTextField
165      */
166     protected JTextField getKeyStoreLocationTextField() {
1670        if (this.keyStoreLocationTextField == null) {
1680            this.keyStoreLocationTextField = new JTextField();
1690            this.keyStoreLocationTextField.setEditable(false);
1700            this.keyStoreLocationTextField.setText(!("" + ConfigurationManager
1710                    .getInstance().getKeyRingLocation())
172                     .equalsIgnoreCase("null") ? ""
173                     + ConfigurationManager.getInstance().getKeyRingLocation()
174                     : "A key ring in not yet defined!");
175         }
1760        return keyStoreLocationTextField;
177     }
1780 
179     /**
180      * @return the securityLevelComboBox
181      */
182     protected JComboBox getSecurityLevelComboBox() {
1830        if (this.securityLevelComboBox == null) {
1840            this.securityLevelComboBox = new JComboBox();
1850            for (int i = 0; i < SecurityLevel.level.length; i++) {
1860                this.securityLevelComboBox.addItem(SecurityLevel.level[i]);
1870                if (ConfigurationManager.getInstance()
1880                        .getDefaultBackupSecurityLevel().toString()
1890                        .equalsIgnoreCase(SecurityLevel.level[i]))
1900                    this.securityLevelComboBox
1910                            .setSelectedItem(SecurityLevel.level[i]);
192             }
1930            this.securityLevelComboBox
194                     .setToolTipText("If private each created backuo will be encrypted and signed, will be not otherwise.");
195         }
1960        return securityLevelComboBox;
197     }
198  
199     /**
200      * @return the securityLevelPanel
201      */
202     protected JPanel getSecurityLevelPanel() {
2030        if (this.securityLevelPanel == null) {
2040            this.securityLevelPanel = new JPanel();
2050            this.securityLevelPanel.setBorder(new TitledBorder(
206                     "Backup Security Level"));
2070            this.securityLevelPanel.setLayout(new BorderLayout());
2080            this.securityLevelPanel.add(this.getSecurityLevelComboBox(),
209                     BorderLayout.CENTER);
210  
211         }
2120        return securityLevelPanel;
213     }
214  
215     /**
216      * @return Returns the authenticatePeerDownloadCheckBox.
217      */
218     protected JCheckBox getAuthenticatePeerDownloadCheckBox() {
2190        if (this.authenticatePeerDownloadCheckBox == null) {
2200            this.authenticatePeerDownloadCheckBox = new JCheckBox();
2210            this.authenticatePeerDownloadCheckBox
222                     .setToolTipText("Enables an X509Certificate check between the peer that is trying to download a backup and its owner.");
2230            this.authenticatePeerDownloadCheckBox
224                     .setSelected(ConfigurationManager.getInstance()
225                             .isEnabledPeerDownloadAuthentication());
2260            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         }
2380        return authenticatePeerDownloadCheckBox;
239     }
240  
241     /**
242      * @return Returns the authenticatePeerDownloadPanel.
243      */
244     protected JPanel getAuthenticatePeerDownloadPanel() {
2450        if (this.authenticatePeerDownloadPanel == null) {
2460            this.authenticatePeerDownloadPanel = new JPanel();
2470            this.authenticatePeerDownloadPanel.setBorder(new TitledBorder(
248                     "Download Authentication"));
2490            this.authenticatePeerDownloadPanel.setLayout(new BorderLayout());
2500            this.authenticatePeerDownloadPanel
251                     .add(this.getAuthenticatePeerDownloadCheckBox(),
252                             BorderLayout.CENTER);
253         }
2540        return authenticatePeerDownloadPanel;
255     }
256 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.