Documente Academic
Documente Profesional
Documente Cultură
We are also very highly grateful to Mr. Rocky Jagtiani for his interest
and encouragement in the progress of our project.
Had it not been the sincere efforts of our project guide Mr. Dilip N. it
would have been the next to impossible for the completion of our project. His
efforts have been very helpful in the development of our project to solve
different problems that have aroused during the implementation of our
application.
1. Problem Definition
Abstract
Recommended Solution
2. Analysis of the problem definition
Development of Algorithm
4. Implementation
Explanation of modules
5. Conclusion
Future Enhancement
Annexure 1:
Annexure 2:
List of references
CHAPTER 1
PROBLEM DEFINITION
ABSTRACT
SSL (Secure Socket Layer) is the most popular protocol used in the
Internet for facilitating secure communication. It is a set of specifications that
allow two applications to communicate with each other via the Internet, in a
secure environment. The explosive growth in Internet for supporting E-
commerce and other exchange of sensitive information has highlighted the
need for efficiently supporting secure communications between clients and
servers by establishing a secure channel between them.
Secure Sockets Layer (SSL) technology protects the Web site or any
application and makes it easy for the visitors to trust in three essential ways:
Home users, small, medium and big corporate all suffer from the threat
of constant attacks from Viruses, Worms and Trojans etc. by hacker. If the
hacker tampers the confidential data flowing through the network, it would be
a threat to an organization or personnel. The receiver would be fooled by the
hacker. Hence, the confidentiality and the integrity of the data is breached.
Exactly how safe is it to submit credit card details over the net?
Confidentiality.
Integrity.
Non-repudiation.
When the Client enters his Login details, the details are transferred
securely through the encrypted channel to the Server for authentication. These
entered details are the sensitive information (like Password). These details are
sent in encrypted format so as to avoid hacking of original data i.e. even if the
hacker hacks the encrypted data, modify it, and sends this modified data to the
Server, it would come to know thus by comparing the hash values.
PROGRAMMING LANGUAGE USED:
Java
Reason being:
The javax.swing and java.awt packages are used to develop GUI of the
Server and Client applications. They provide a rich set of different Java APIs
for building up the two applications.
Platform Independence
Extensible
Object Oriented
Customizable
Configurable
1. jdk1.6
2. Text editor (Notepad)
CHAPTER 2
ANALYSIS AND DESIGN
CHAPTER 3
OBJECT ORIENTED DESIGN
DEVELOPMENT OF ALGORITHM:
STEPS IN ALGORITHM:
step: 12 When client clicks on “OK”, SSL cipher suit does encrypts &
compresses the login details by selecting supported algorithm
exchanged during handshake.
step: 13 Encrypted output send to the server where server does decryption
of the receiver details by selecting appropriate algorithm
exchanged during handshake.
step: 14 Server verifies the details by comparing details with its hash
table.
1. Steps to show how virtual CA establishes and acts as a third party between
Client & Server for authenticate to each other.
For setting up a CA of our own, we use our own JSTK utility certtool.
Setting up a CA with certtool is quite straightforward. You do so by
executing the "certtool” command with “setupca”, an option from
JSTK home directory and specifying appropriate parameters:
2. Create a Server.
Here we first validate the Login details at client side where we check for
the following:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.awt.Component;
import java.io.*;
import java.net.*;
import java.security.*;
import javax.net.*;
import javax.net.ssl.*;
import javax.security.cert.*;
options=new JMenu("Option");
help=new JMenuItem("Help");
help.setAccelerator(KeyStroke.getKeyStroke
(KeyEvent.VK_H,InputEvent.SHIFT_MASK));
loginItem.addActionListener(new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
unamePwd = JOption.showUserLoginDialog(null,"
Login Dialog", "Username: ", "Password: ");
}
});
exitItem.addActionListener(new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
if(JOptionPane.showConfirmDialog(null,"Do you want to
Logout?","LogOut", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE)==0)
{
JOptionPane.showMessageDialog(null,"You have been
successfully LoggedOut" ,"LoggedOut", 1);
dispose();
System.exit( 0 );
}
}
});
aboutus.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
new AboutUs();
}
});
help.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
callingHTML(new URL("http://localhost/help.htm"));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
});
menuBar.add( fileMenu );
fileMenu.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
fileMenu.add( loginItem );
loginItem.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
fileMenu.add( exitItem );
exitItem.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
menuBar.add(options);
options.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
options.add(aboutus);
aboutus.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
options.add(help);
help.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
return menuBar;
} /*End: buildMenuBar() */
if(sock.isConnected())
{
JOptionPane.showMessageDialog(this,"Client-Connected”,
"Done", JOptionPane.INFORMATION_MESSAGE);
fileMenu.setEnabled(true);
options.setEnabled(true);
Font f1=new Font("Dialog",Font.BOLD,16);
JLabel l1=new JLabel("Secure channel has been established
between the Client and Server");
add(l1);
l1.setFont(f1);
l1.setBounds(60,20,500,17);
img=new ImageIcon("ssl-lock.gif");
jb=new JButton(img);
getContentPane().add(jb);
jb.setBounds(380,185,40,40);
jb.setCursor(Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
jb.addActionListener(new ActionListener()
{
public void actionPerformed( ActionEvent event)
{
u=new TabUtil();
u.printSocketInfo(sock);
}
});
exitItem.setEnabled(false);
for(int i=0;i<2;i++)
{ toServer.println(unamePwd[i]);}
break;
}
}
String y=fromServer.readLine();
if(y.equals("y"))
{
JOptionPane.showMessageDialog(this,"Authentication
Successfull","Done",
JOptionPane.INFORMATION_MESSAGE);
flag=1;
}
else
{
JOptionPane.showMessageDialog(this,"Authentication
Failure”, "Failed",JOptionPane.ERROR_MESSAGE);
unamePwd=null;
unamePwd = JOption.showUserLoginDialog(null,
"Login Dialog”,"Username:", "Password:");
continue loop1;
}
if(flag==1) /*Open: if(..)1*/
{
loginItem.setEnabled(false);
exitItem.setEnabled(true);
chatLine.setEnabled(true);
chatText.setEnabled(true);
chatLine.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String s = chatLine.getText();
if (!s.equals(""))
{
toAppend.append("OUTGOING: " + s + "\n");
chatLine.selectAll();
toSend.append(s + "\n");
chatText.append(toAppend.toString());
toAppend.setLength(0);
if (toSend.length() != 0)
{
toServer.println(toSend);
toServer.flush();
toSend.setLength(0);
}
}
}
}); break;
} /*End: if(..) 1*/
} /*End: loop1:while(true) */
}
} /*End: try */
catch(ConnectException ce)
{
JOptionPane.showMessageDialog(this,"Please start the Server",
"Error",JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch(SSLException se)
{
JOptionPane.showMessageDialog(null,"Server has been shut
down", "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch(Exception exe)
{
exe.printStackTrace();
}
} /*End: run1() */
KeyManagerFactory.getInstance("SunX509");
TrustManagerFactory tmf=
TrustManagerFactory.getInstance(“SunX509");
KeyStore ks=KeyStore.getInstance("JCEKS");
KeyStore ts=KeyStore.getInstance("JCEKS");
ks.load(new FileInputStream(KEYSTORE),
STOREPASS.toCharArray());
ts.load(new FileInputStream(TRUSTSTORE),
STOREPASS.toCharArray());
kmf.init(ks,ALIASPASS.toCharArray());
tmf.init(ts);
sslcontext.init(kmf.getKeyManagers(),
tmf.getTrustManagers(),null);
ssf = sslcontext.getSocketFactory();
return ssf;
}
catch(Exception e)
{ e.printStackTrace(); }
}
else
{
return (SSLSocketFactory) SSLSocketFactory.getDefault();
} return null;
} /*End: getClientSocketFactory()*/
} /*End: Client1 class*/
EXPLAINATION
The class Client1.java is the Client side of a secure network connection.
The Java API classes and interfaces to perform the functions of establishing
connection between Client and Server via sockets reside in the packages
java.net and javax.net. They support many different sequences of class
instantiations and method invocations to establish a connection. Many other
packages for building the secure applications are imported.
The random number used in the process of generating the secret key is
kept null, so the default random number seed will be used.
SERVER APPLICATION
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.security.*;
import javax.net.*;
import javax.net.ssl.*;
import javax.security.cert.*;
cmdStart.setText("Start");
getContentPane().add(cmdStart);
cmdStart.setBounds(200, 120, 70, 30);
chatText=new JTextArea();
sp=new JScrollPane(chatText);
chatText.setEditable(false);
add(sp);
sp.setBounds(25,55,155,215);
} /* End: initComponents()*/
private void exitForm(WindowEvent evt)
{
System.exit(0);
}
ssf = Server1.getServerSocketFactory("TLS");
ss = (SSLServerSocket) ssf.createServerSocket(port);
sock = (SSLSocket) ss.accept();
while (true)
{
try
{
a = fromClient.readLine();
b = fromClient.readLine();
if (y == true)
{
getContentPane().setLayout(null);
toClient.println("y");
flag=1;
}
else
{
toClient.println("n");
}
} /*End: if(..)1 */
} /*End: try */
catch (SocketException e)
{
JOptionPane.showMessageDialog(null,"Client is
disconnected", "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch(Exception exe)
{
exe.printStackTrace();
}
while(true)
{
s = fromClient.readLine();
catch (SocketException e)
{
JOptionPane.showMessageDialog(null, "Client is disconnected",
"Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch (Exception exc)
{ exc.printStackTrace(); }
}
} /*End: MyAsync class*/
ks.load(new FileInputStream(KEYSTORE),
STOREPASS.toCharArray());
kmf.init(ks,ALIASPASS.toCharArray());
sslcontext.init(kmf.getKeyManagers(),null,null);
ssf = sslcontext.getServerSocketFactory();
return ssf;
}
catch(Exception e)
{
e.printStackTrace();
}
}
else
{
return(SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
} return null;
} /* End: getServerSocketFactory()*/
} /*End: Server1 class*/
EXPLAINATION
The Server1.java is the Server side of a secure network connection.
Similar to Client1.java the Java API classes and interfaces to perform the
functions of establishing connection between Client and Server via sockets
reside in the package java.net and javax.net. Many other packages for building
the secure applications are imported.
When we start the Server, it waits for the Client connection. When the
Server is started a new thread is created i.e. run() method from MyAsync class
is called. This method calls the method getServerSocketFactory(type). In this
method, a JSSE-specific collection of key manager is created, using the
JCEKS keystore object: ks.
The random number used in the process of generating the secret key is
kept null, so the default random number seed will be used.
while(true)
{
if(n==OK_OPTION)
{
if(((username.getText().length())==0)&& /*open: if(..) 1*/
((password.getText().length())==0))
{ showMessageDialog(null,"Enter Username and Password" ,
"Error", JOptionPane.ERROR_MESSAGE);
break;
} /*close: if(..) 1*/
else /*open: else 1*/
{
if(((username.getText().length())>=6)&& /*open: if(..) 2*/
((username.getText().length())<=10))
{
uname=username.getText();
} /*close: if(..) 2*/
else /*open: else 2*/
{
if((username.getText().length())==0)
{
showMessageDialog(null, "Username should be of 6-10
characters","Error",JOptionPane.ERROR_MESSAGE);
break;
}
else
{
if(((username.getText().length())<6)||
((username.getText().length())>10))
{
showMessageDialog(null, "Username should be of 6-10
characters","Error",JOptionPane.ERROR_MESSAGE);
break;
}
}
} /*close: else 2*/
EXPLAINATION
These are checked to ensure the user enters correct data. The object
with Username and Password: unamePwd is returned back to the class Client1
where the object is passed to the Server through a secure channel in the
encrypted format.
HASHTABLE COMPARISON
import java.util.*;
import java.io.*;
class HT
{
Hashtable log=new Hashtable();
Enumeration e;
private String a,b;
private boolean flag;
HT()
{
log.put(new String("Ashwini"),new String("ashwini"));
log.put(new String("Ashwinip"),new String("ashwinipatil"));
}
while(e.hasMoreElements())
{
String bal=(String) e.nextElement();
if(a.equals(bal))
{
if(b.equals((String)log.get(bal)))
{
flag=true;
break;
}
}}
if(flag==true)
{
return true;
}
else
{
return false;
}
} /*End: welcome()*/
} /*End: HT class*/
EXPLAINATION
This class stores the details that are loaded each time HT() is called.
When the Server send the data to this class to check whether the given details
matches with the store details, a welcome(string, string) method is called that
returns a Boolean value.
import javax.net.ssl.*;
import java.net.*;
import java.security.*;
import javax.security.cert.*;
import javax.security.cert.X509Certificate;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
import java.lang.*;
import java.awt.event.*;
import java.math.BigInteger;
f2=new Font("Dialog",Font.PLAIN,12);
JLabel l4=new JLabel(" All application policies " );
add(l4);
l4.setFont(f2);
l4.setBounds(30,70,300,35);
JLabel l5=new
JLabel("-----------------------------------------------------
---------------------------------");
add(l5);
l5.setBounds(15,200,385,15);
add(l8);
l8.setFont(f1);
l8.setBounds(15,350,75,35);
add(l9);
l9.setFont(f1);
l9.setBounds(175,350,30,35);
Date d1=remoteCerts[0].getNotBefore();
Date d2=remoteCerts[0].getNotAfter();
String s2=sdf.format(d1).toString();
String s4=sdf.format(d2).toString();
dn = dn.substring(i + 3);
char[] dncs = dn.toCharArray();
BigInteger b=remoteCerts[0].getSerialNumber();
String sn=b.toString(16);
String suite=sess.getCipherSuite();
String signalg=remoteCerts[0].getSigAlgName();
Principal p1=remoteCerts[0].getIssuerDN();
String pIssue=p1.toString();
String d1=remoteCerts[0].getNotBefore().toString();
String d2=remoteCerts[0].getNotAfter().toString();
Principal p2=remoteCerts[0].getSubjectDN();
String pSub=p2.toString();
PublicKey key1=remoteCerts[0].getPublicKey();
String pubKey=key1.toString();
InetSocketAddress remoteAddr;
remoteAddr= (InetSocketAddress) sock.getRemoteSocketAddress();
String remote=remoteAddr.toString();
String col[]={"Field","Value"};
String data[] []={{"Protocol Version",proto},
{"Serial Number",sn},
{"Cipher Suite",suite},
{"Signature Algorithm",signalg},
{"Issuer",pIssue},
{"Valid from",d1},
{"Valid to",d2},
{"Subject",pSub},
{"Public key",pubKey},
{"Remote Address",remote}
};
table.setRowHeight(20);
add(jta);
jta.setEditable(false);
jta.setLineWrap(true);
add(outputPane);
outputPane.setBounds(25,250,325,150);
table.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{ printData(table); }
});
EXPLAINATION
It also displays all the information that is exchanged between the Server and
the Client in DetailInfo class which include protocol version, cipher suite, signature
algorithm etc. Hance, this class displays all the socket information.
GUI SNAPSHOTS
Screen 1: Server.
This displays the details that are exchanged between the Client and
Server during handshake. It includes the information regarding the cipher suite
that is being selected and used while secure transmission of data, the 1024 bits
public key of the Server, and other information.
This is 1024 bits public key of the Server that it is uses during
communication.
Screen 6: Login Dialog
The login dialog box pops up to accept the Username and Password
from the user of the application when the user clicks on Login or Shift+L on
MenuBar within Click Me option..
Screen 7: Successful Authentication
If the entered details match with the stores details at Server , the Server
sends positive response to the Client and hence the Client application displays
“Authentication Successful” else “Authentication Failure”.
Screen 8: Messages exchanged through secure channel.
When the Client tries to connect with the Server and if the Server has
not been started initially, it pops up a message “Please start the Server” and
exits the application.
Screen 9: Help File
The HTML help file created gives the information on the entire topic of
SSL. It describes the detail algorithm that has been implemented in our project.
It also gives the detail information on how to use our project along with
the screenshots to make it more understandable and easy.
It explains the need of SSL today and the future applications of the
same, different mechanisms used in developing a strong security in the
network applications. How security is thus maintained between a Client and
Server.
CHAPTER 5
CONCLUSION
APPLICATIONS
FUTURE ENHANCEMENTS:
Can be made more secure and flexible way to access data remotely
by implementing different cipher suites and usage of firewalls to
block the access to the secure resource over network.
APPLICATIONS DUE TO FUTURE ENHANCEMENTS:
LIST OF REFERENCES
BOOKS REFERRED:
JAVA Complete Reference by Herbert Schildt.
PROJECT IDEAS:
www.planetsourcecode.com
www.ieeexplore.ieee.org
www.rockysir.info
www.crazyengineers.com/forum/project-ideas
www.projectideas.blogspot.com
www.docs.sun.com
www.stilius.net/java/java_ssl.com
www.java.sun.com/j2se/1.5.0/docs/guide/
security/jsse/JSSERefGuide.html
www.ietf.org
www.ssl-protocol.blogspot.com
www.roseindia.net
www.javaworld.com
CONTACT INFORMATION:
For any queries please contact:
Ashwini P. Patil
patil.ashu01@gmail.com
Ashish Pandya
ashishpandya50@gmail.com
Santosh Vaidya
santy.aries@gmail.com
Gaurav Shroff
gauravshroff555@gmail.com
THANK YOU