/********************************************************
* Speaker Verification Implemented Security *
* CA4 Project *
* Written by: Ronan Crowley (97084603) *
* and Paul Connolly (97307599) *
********************************************************/
import Audio.*;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class setSecurity extends JDialog {
String[] values = {"25 %","20 %","15 %","10 %","5 %","2 %","1 %","0.5 %","0.1 %","0.05 %","0.01 %" };
double[] results = {0.6742, 0.8415, 1.0364, 1.2817, 1.6452, 2.0542, 2.3268, 2.5762, 3.0905, 3.2908, 3.7191};
JList JList1 = new JList();
String username;
ObjectOutputStream output;
JTextArea area = new JTextArea();
public setSecurity (JDialog parent, ObjectOutputStream ostream, String name, double probAnti, double probRejYou)
{
super (parent);
username = name;
output = ostream;
this.setTitle("Select Personal Level of Security");
// setIconImage(Toolkit.getDefaultToolkit().createImage(setSecurity.class.getResource("sv.gif")));
getContentPane().setLayout(null);
setSize(405,390);
setVisible(false);
area.setText("Currently there is a "+(probAnti*100)+"% chance of another user logging in as you.\nCurrently there is a "+(probRejYou*100)+"% chance of you being rejected\nPlease select your new security level from the list below.");
area.setBorder(BorderFactory.createRaisedBevelBorder());
area.setBounds(24,30,370,70);
area.setEditable(false);
getContentPane().add(area);
JList1.setListData( values );
JList1.setBounds(124,125,139,220);
JList1.setBorder(BorderFactory.createRaisedBevelBorder());
getContentPane().add(JList1);
SymListSelection lSymListSelection = new SymListSelection();
JList1.addListSelectionListener(lSymListSelection);
}
public void setVisible(boolean b)
{
if (b)
setLocation(150, 150);
super.setVisible(b);
}
/* static public void main(String args[])
{
double a = 0.0;
double b = 0.0;
(new JDialog1(args[0],a,b)).setVisible(true);
// JDialog1(a,b);
}*/
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension size = getSize();
super.addNotify();
if (frameSizeAdjusted)
return;
frameSizeAdjusted = true;
// Adjust size of frame according to the insets
Insets insets = getInsets();
setSize(insets.left + insets.right + size.width, insets.top +insets.bottom + size.height);
}
// Used by addNotify
boolean frameSizeAdjusted = false;
class SymListSelection implements javax.swing.event.ListSelectionListener
{
public void valueChanged(javax.swing.event.ListSelectionEvent event)
{
Object object = event.getSource();
if (object == JList1)
JList1_valueChanged(event);
}
}
void JList1_valueChanged(javax.swing.event.ListSelectionEvent event)
{
JOptionPane.showMessageDialog(null, values[JList1.getSelectedIndex()],"New Security Level = ", JOptionPane.INFORMATION_MESSAGE);
//send value to re-calculate new threshold !
try {
output.writeObject(username+";"+results[JList1.getSelectedIndex()]);
output.flush();
}
catch (EOFException eof) {
System.out.println("Server terminated connection");
}
catch ( IOException e ) {
e.printStackTrace();
}
//calcThreshold thresholdobject = new calcThreshold();
//double threshold = thresholdobject.getThreshold(username, results[JList1.getSelectedIndex()]);
dispose();
}
}