Coverage details for 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 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  
390@SuppressWarnings("serial") //$NON-NLS-1$
400public class SecurityConfigurationPanel extends JPanel {
41  
42     private JPanel passwordProtectPanel;
430 
440    private JCheckBox passwordProtectCheckBox;
450 
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     
590 
600    public SecurityConfigurationPanel() {
610        initialize();
620    }
630 
640    protected void initialize() {
650        TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.securityconfiguration")); //$NON-NLS-1$
660        this.setBorder(titledBorder);
670        this.setLayout(new GridLayout(3, 1));
680        this.add(getPasswordProtectPanel(), null);
690        this.add(getAsymmetricCryptographyPanel(), null);
700        this.add(getSymmetricCryptographyPanel(), null);
710    }
720 
73     /**
74      * @return Returns the passwordProtectPanel.
75      */
760    protected JPanel getPasswordProtectPanel() {
770        if (passwordProtectPanel == null) {
780            passwordProtectPanel = new JPanel();
790            TitledBorder titledBorder = new TitledBorder(Messages.getString("common.passwordprotect")); //$NON-NLS-1$
800            passwordProtectPanel.setBorder(titledBorder);
810            passwordProtectPanel.setLayout(new BorderLayout());
820            passwordProtectPanel.add(getAutomaticPasswordProtectPanel(),
830                    BorderLayout.CENTER);
840            passwordProtectPanel.add(getPasswordProtectCheckBox(),
850                    BorderLayout.WEST);
860 
870        }
880        return passwordProtectPanel;
890    }
90  
91     /**
92      * @return Returns the passwordProtectCheckBox.
93      */
940    protected JCheckBox getPasswordProtectCheckBox() {
950        if (passwordProtectCheckBox == null) {
960            passwordProtectCheckBox = new JCheckBox();
970            passwordProtectCheckBox
980                    .setToolTipText(Messages.getString("panel.securityconfigurationpanel.message1")); //$NON-NLS-1$
990            passwordProtectCheckBox.setSelected(ConfigurationManager
1000                    .getInstance().isPasswordProtect());
1010            passwordProtectCheckBox.addActionListener(new ActionListener() {
1020                public void actionPerformed(ActionEvent arg0) {
103                     ConfigurationManager.getInstance().setPasswordProtect(
104                             passwordProtectCheckBox.isSelected());
105                 }
106             });
1070        }
1080        return passwordProtectCheckBox;
1090    }
110  
111     /**
112      * @return Returns the automaticPasswordProtectCheckBox.
113      */
1140    protected JCheckBox getAutomaticPasswordProtectCheckBox() {
1150        if (automaticPasswordProtectCheckBox == null) {
1160            automaticPasswordProtectCheckBox = new JCheckBox();
1170            automaticPasswordProtectCheckBox.setSelected(ConfigurationManager
1180                    .getInstance().isAutomaticPasswordProtected());
1190            automaticPasswordProtectCheckBox
1200                    .addActionListener(new ActionListener() {
1210                        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  
1370        }
1380        return automaticPasswordProtectCheckBox;
1390    }
140  
141     /**
142      * @return Returns the automaticPasswordProtectPanel.
143      */
1440    protected JPanel getAutomaticPasswordProtectPanel() {
1450        if (automaticPasswordProtectPanel == null) {
1460            automaticPasswordProtectPanel = new JPanel();
1470            TitledBorder titledBorder = new TitledBorder(Messages.getString("common.automaticprotection")); //$NON-NLS-1$
1480            automaticPasswordProtectPanel.setBorder(titledBorder);
1490            automaticPasswordProtectPanel.setLayout(new BorderLayout());
1500            automaticPasswordProtectPanel.add(
1510                    getAutomaticPasswordProtectTimeChooser(),
1520                    BorderLayout.CENTER);
1530            automaticPasswordProtectPanel.add(
1540                    getAutomaticPasswordProtectCheckBox(), BorderLayout.EAST);
1550        }
1560        return automaticPasswordProtectPanel;
1570    }
158  
159     /**
160      * @return Returns the automaticPasswordProtectTimeChooser.
161      */
1620    protected JTimeChooser getAutomaticPasswordProtectTimeChooser() {
1630        if (automaticPasswordProtectTimeChooser == null) {
1640            automaticPasswordProtectTimeChooser = new JTimeChooser();
1650            GregorianCalendar gc = new GregorianCalendar(0, 0, 0, 0, 0,
1660                    ConfigurationManager.getInstance().getLogoutScheduleRate());
1670            automaticPasswordProtectTimeChooser.setValue(gc.getTime());
1680 
1690        }
1700        return automaticPasswordProtectTimeChooser;
1710    }
172  
173     /**
174      * @return Returns the asymmetricCryptographyPanel.
175      */
1760    protected JPanel getAsymmetricCryptographyPanel() {
1770        if (asymmetricCryptographyPanel == null) {
1780            asymmetricCryptographyPanel = new JPanel();
1790            TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.common.asymmetriccryptographysettings")); //$NON-NLS-1$
1800            asymmetricCryptographyPanel.setBorder(titledBorder);
1810            asymmetricCryptographyPanel.setLayout(new GridLayout(1,2));
1820            JPanel publicKeyPanel = new JPanel();
1830            publicKeyPanel.setLayout(new BorderLayout());
1840            publicKeyPanel.setBorder(new TitledBorder(Messages.getString("common.publickey"))); //$NON-NLS-1$
1850            publicKeyPanel.add(getAsymmetricCryptographyPublicKeyTextArea(),BorderLayout.CENTER);
1860            
1870            JPanel privateKeyPanel = new JPanel();
1880            privateKeyPanel.setLayout(new BorderLayout());
1890            privateKeyPanel.setBorder(new TitledBorder(Messages.getString("common.privatekey"))); //$NON-NLS-1$
1900            privateKeyPanel.add(getAsymmetricCryptographyPrivateKeyTextArea(),BorderLayout.CENTER);
1910            
1920            asymmetricCryptographyPanel.add(publicKeyPanel);
1930            asymmetricCryptographyPanel.add(privateKeyPanel);
1940 
1950        }
1960        return asymmetricCryptographyPanel;
1970    }
198  
199     /**
200      * @return Returns the symmetricCryptographyPanel.
201      */
2020    protected JPanel getSymmetricCryptographyPanel() {
2030        if (symmetricCryptographyPanel == null) {
2040            symmetricCryptographyPanel = new JPanel();
2050            TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.securityconfigurationpanel.common.symmetriccryptographysettings")); //$NON-NLS-1$
2060            symmetricCryptographyPanel.setBorder(titledBorder);
2070            symmetricCryptographyPanel.setLayout(new GridLayout(1,2));
2080            symmetricCryptographyPanel.add(getSymmetricCryptographyTextArea());
2090        }
2100        return symmetricCryptographyPanel;
2110    }
212  
213     /**
214      * @return Returns the asymmetricCryptographyPrivateKeyTextArea.
215      */
2160    protected JTextArea getAsymmetricCryptographyPrivateKeyTextArea() {
2170        if(asymmetricCryptographyPrivateKeyTextArea == null){
2180            asymmetricCryptographyPrivateKeyTextArea = new JTextArea();
2190        }
2200        return asymmetricCryptographyPrivateKeyTextArea;
2210    }
222  
223     /**
224      * @return Returns the asymmetricCryptographyPublicKeyTextArea.
225      */
2260    protected JTextArea getAsymmetricCryptographyPublicKeyTextArea() {
2270        if(asymmetricCryptographyPublicKeyTextArea == null){
2280            asymmetricCryptographyPublicKeyTextArea = new JTextArea();
2290        }
2300        return asymmetricCryptographyPublicKeyTextArea;
2310    }
232  
233     /**
234      * @return Returns the symmetricCryptographyTextArea.
235      */
2360    protected JTextArea getSymmetricCryptographyTextArea() {
2370        if(symmetricCryptographyTextArea == null){
2380            symmetricCryptographyTextArea = new JTextArea();
2390        }
2400        return symmetricCryptographyTextArea;
2410    }
242 }

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.