© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Create the Tree Structure Using Java Applet

Description:

This program is to create the tree structure for the users in the group. From the client side you can create and remove the member from the group. The memberís details are updated in the server. Based on the number of members in the group, it is sub divided. Each group will have two members and every member in the group will have their unique key and the common group key. While the classification of the group, the group key will change. The tree structure displayed will have their key with the name of the group or member. KeyGenerate () method will generate the key for the members of the tree and TreeactionPerformed () method will draw the tree structure.

Crete the Tree Structure Using Java Applet :

/* * KeyClient.java * * */ import javax.swing.*; import java.util.*; import java.math.*; import java.net.*; import java.io.*; /** * * @author student */ public class KeyClient extends javax.swing.JFrame { BigInteger PrimeNo=new BigInteger("359"); BigInteger IndividualKey; BigInteger GroupKey; Vector GroupMemberNames; /** Creates new form KeyClient */ public KeyClient() { initComponents(); setLocation(125,125); setSize(675,500); setResizable(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); MemberList = new javax.swing.JList(); jLabel2 = new javax.swing.JLabel(); Create = new javax.swing.JButton(); Remove = new javax.swing.JButton(); Exit = new javax.swing.JButton(); getContentPane().setLayout(null); setTitle("GroupKeyClient"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 36)); jLabel1.setText("GroupKey Client"); getContentPane().add(jLabel1); jLabel1.setBounds(180, 10, 260, 50); jScrollPane1.setViewportView(MemberList); getContentPane().add(jScrollPane1); jScrollPane1.setBounds(10, 90, 190, 370); jLabel2.setFont(new java.awt.Font("Dialog", 1, 16)); jLabel2.setText("GroupMembers"); getContentPane().add(jLabel2); jLabel2.setBounds(30, 60, 120, 21); Create.setText("Create "); Create.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CreateActionPerformed(evt); } }); getContentPane().add(Create); Create.setBounds(360, 150, 130, 26); Remove.setText("Remove"); Remove.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RemoveActionPerformed(evt); } }); getContentPane().add(Remove); Remove.setBounds(360, 220, 130, 26); Exit.setText("Exit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitActionPerformed(evt); } }); getContentPane().add(Exit); Exit.setBounds(360, 290, 130, 26); pack(); }//GEN-END:initComponents private void RemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveActionPerformed System.out.println("Inside the Remove"); try{ String MemberName=(String)MemberList.getSelectedValue(); if(MemberName.length()>0){ System.out.println("The Member Name is:"+MemberName); Vector ClientDetails=new Vector(); ClientDetails.addElement("MemberRemove"); ClientDetails.addElement(MemberName); System.out.println("client send data to server is:"+ClientDetails); Socket cs=new Socket("localhost",6878); ObjectOutputStream OOS=new ObjectOutputStream(cs.getOutputStream()); OOS.writeObject(ClientDetails); ObjectInputStream OIS=new ObjectInputStream(cs.getInputStream()); Vector ServerData=(Vector)OIS.readObject(); System.out.println("The Server Received output is:"+ServerData); GroupKey=(BigInteger)ServerData.elementAt(1); GroupMemberNames=(Vector)ServerData.elementAt(2); MemberList.setListData(GroupMemberNames); OOS.close(); OOS.flush(); }else{ JOptionPane.showMessageDialog(null,"Please Select Memebr First"); } }catch(ConnectException e){ System.out.println("Please ensure connection is found are not"+e); JOptionPane.showMessageDialog(null,"Server Name May be change or Server is Not Yet Started"); }catch(Exception e1){ System.out.println("Error from create"+e1); JOptionPane.showMessageDialog(null,"Error"+e1.toString()); } }//GEN-LAST:event_RemoveActionPerformed private void CreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CreateActionPerformed System.out.println("Inside the Create"); try{ String MemberName=JOptionPane.showInputDialog("Please Enter The Member Name"); System.out.println("The Member Name is:"+MemberName); BigInteger IKey=new BigInteger(8,new Random()); IndividualKey=IKey; Vector ClientDetails=new Vector(); ClientDetails.addElement("MemberJoin"); ClientDetails.addElement(MemberName); ClientDetails.addElement(IKey); System.out.println("client send data to server is:"+ClientDetails); Socket cs=new Socket("localhost",6878); ObjectOutputStream OOS=new ObjectOutputStream(cs.getOutputStream()); OOS.writeObject(ClientDetails); ObjectInputStream OIS=new ObjectInputStream(cs.getInputStream()); Vector ServerData=(Vector)OIS.readObject(); System.out.println("The Server Received output is:"+ServerData); GroupKey=(BigInteger)ServerData.elementAt(1); GroupMemberNames=(Vector)ServerData.elementAt(2); MemberList.setListData(GroupMemberNames); OOS.close(); OOS.flush(); }catch(ConnectException e){ System.out.println("Please ensure connection is found are not"); JOptionPane.showMessageDialog(null,"Server Name May be change or Server is Not Yet Started"); }catch(Exception e1){ System.out.println("Error from create"+e1); JOptionPane.showMessageDialog(null,"Error"+e1.toString()); } }//GEN-LAST:event_CreateActionPerformed private void ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitActionPerformed System.exit(0); }//GEN-LAST:event_ExitActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { new KeyClient().show(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton Exit; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JButton Create; private javax.swing.JButton Remove; private javax.swing.JList MemberList; // End of variables declaration//GEN-END:variables } /* * KeyServer.java * * */ import javax.swing.*; import java.util.*; import java.net.*; import java.math.*; import java.io.*; import java.awt.*; /** * * @author student */ public class KeyServer extends javax.swing.JFrame implements Runnable { boolean Start=false; Vector GroupMemberName=new Vector(); Hashtable GroupMemberIKey=new Hashtable(); Hashtable GMIDDetails=new Hashtable(); BigInteger TotalGroupKey=null; Hashtable SubGroupKey=new Hashtable(); ServerSocket GroupKeyServer; Socket clientValue; int FreeMemberCount=0; int membercount=1; BigInteger PrimeNo=new BigInteger("359"); BigInteger GRNO=new BigInteger("110"); Hashtable keystructureKey=new Hashtable(); Hashtable keystructureName=new Hashtable(); int keystructurecount=1; int keystructureselect=1; Hashtable Left=new Hashtable(); Hashtable Right=new Hashtable(); int Lcount=1; int Rcount=1; Hashtable subkey=new Hashtable(); /** Creates new form KeyServer */ public KeyServer() { initComponents(); setLocation(25,25); setSize(975,700); setResizable(false); try { GroupKeyServer=new ServerSocket(6878); } catch(Exception e) { System.out.println("The server socket Creatio error:"+e); } keystructureKey.put("0","0"); keystructureName.put("0","Head"); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents StartServer = new javax.swing.JButton(); StopServer = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); GroupList = new javax.swing.JList(); Tree = new javax.swing.JButton(); Exit = new javax.swing.JButton(); getContentPane().setLayout(null); setTitle("GroupKeyServer"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); StartServer.setText("StartServer"); StartServer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { StartServerActionPerformed(evt); } }); getContentPane().add(StartServer); //StartServer.setBounds(320, 620, 100, 26); StartServer.setBounds(200, 420, 100, 26); StopServer.setText("StopServer"); StopServer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { StopServerActionPerformed(evt); } }); getContentPane().add(StopServer); //StopServer.setBounds(450, 620, 110, 26); StopServer.setBounds(300, 420, 100, 26); jLabel1.setFont(new java.awt.Font("Dialog", 1, 18)); jLabel1.setText("GroupMemberNames"); getContentPane().add(jLabel1); jLabel1.setBounds(10, 80, 190, 40); jLabel2.setFont(new java.awt.Font("Monotype Corsiva", 1, 36)); jLabel2.setText("GroupKeyServer"); getContentPane().add(jLabel2); jLabel2.setBounds(340, 20, 260, 50); jScrollPane1.setViewportView(GroupList); getContentPane().add(jScrollPane1); jScrollPane1.setBounds(13, 123, 180, 440); Tree.setText("Tree"); Tree.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TreeActionPerformed(evt); } }); getContentPane().add(Tree); Tree.setBounds(400, 420, 100, 26); Exit.setText("Exit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitActionPerformed(evt); } }); getContentPane().add(Exit); Exit.setBounds(660, 620, 60, 26); pack(); }//GEN-END:initComponents private void ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitActionPerformed System.exit(0); }//GEN-LAST:event_ExitActionPerformed public void stop(){ try{ Thread.sleep(500); }catch(Exception e){ } } private void TreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TreeActionPerformed System.out.println("Inside the Tree Action Performed"); Graphics g=getGraphics(); int size=GroupMemberName.size(); //Zero's stage if(size>=1){ g.setColor(new Color(40,40,40)); g.fillOval(575,150,10,10); g.drawString((String)keystructureName.get("1"),515,150); g.drawString("I="+keystructureKey.get("1"),515,160); } //first stage if(size>=2){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("1"),515,150); g.drawString("I="+keystructureKey.get("1"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(450,250,10,10); g.drawLine(580,155,455,255); stop(); g.fillOval(700,250,10,10); g.drawLine(580,155,705,255); stop(); g.drawString((String)keystructureName.get("1"),390,250); g.drawString("I="+keystructureKey.get("1"),390,260); stop(); g.drawString((String)keystructureName.get("2"),640,250); g.drawString("I="+keystructureKey.get("2"),640,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } //Second stage if(size>=3){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("1"),390,250); g.drawString("I="+keystructureKey.get("1"),390,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(375,350,10,10); g.drawLine(455,255,380,355); stop(); g.fillOval(500,350,10,10); g.drawLine(455,255,505,355); stop(); g.drawString((String)keystructureName.get("1"),315,350); g.drawString("I="+keystructureKey.get("1"),315,360); stop(); g.drawString((String)keystructureName.get("3"),440,350); g.drawString("I="+keystructureKey.get("3"),440,360); stop(); g.drawString("S="+subkey.get("1"),390,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } if(size>=4){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("2"),640,250); g.drawString("I="+keystructureKey.get("2"),640,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(650,350,10,10); g.drawLine(705,255,655,355); stop(); g.fillOval(800,350,10,10); g.drawLine(705,255,805,355); stop(); g.drawString((String)keystructureName.get("2"),590,350); g.drawString("I="+keystructureKey.get("2"),590,360); stop(); g.drawString((String)keystructureName.get("4"),740,350); g.drawString("I="+keystructureKey.get("4"),740,360); stop(); g.drawString("S="+subkey.get("2"),640,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } //3stage if(size>=5){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("1"),315,350); g.drawString("I="+keystructureKey.get("1"),315,360); g.drawString("S="+subkey.get("1"),390,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(325,450,10,10); g.drawLine(380,355,330,455); stop(); g.fillOval(425,450,10,10); g.drawLine(380,355,430,455); stop(); g.drawString((String)keystructureName.get("1"),265,450); g.drawString("I="+keystructureKey.get("1"),265,460); stop(); g.drawString((String)keystructureName.get("5"),365,450); g.drawString("I="+keystructureKey.get("5"),365,460); stop(); g.drawString("S="+subkey.get("3"),315,360); stop(); g.drawString("S="+subkey.get("1"),390,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } if(size>=6){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("3"),440,350); g.drawString("I="+keystructureKey.get("3"),440,360); g.drawString("S="+subkey.get("1"),390,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(450,450,10,10); g.drawLine(455,450,505,350); stop(); g.fillOval(550,450,10,10); g.drawLine(505,355,555,455); stop(); g.drawString((String)keystructureName.get("3"),390,450); g.drawString("I="+keystructureKey.get("3"),390,460); stop(); g.drawString((String)keystructureName.get("6"),490,450); g.drawString("I="+keystructureKey.get("6"),490,460); stop(); g.drawString("S="+subkey.get("4"),440,360); stop(); g.drawString("S="+subkey.get("1"),390,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } if(size>=7){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("2"),590,350); g.drawString("I="+keystructureKey.get("2"),590,360); g.drawString("S="+subkey.get("2"),640,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(600,450,10,10); g.drawLine(655,355,605,455); stop(); g.fillOval(710,450,10,10); g.drawLine(655,355,715,455); stop(); g.drawString((String)keystructureName.get("2"),540,450); g.drawString("I="+keystructureKey.get("2"),540,460); stop(); g.drawString((String)keystructureName.get("7"),660,450); g.drawString("I="+keystructureKey.get("7"),660,460); stop(); g.drawString("S="+subkey.get("5"),590,360); stop(); g.drawString("S="+subkey.get("2"),640,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } if(size>=8){ g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("4"),740,350); g.drawString("I="+keystructureKey.get("4"),740,360); g.drawString("S="+subkey.get("2"),640,260); g.drawString("G="+keystructureKey.get("0"),515,160); stop(); g.setColor(new Color(40,40,40)); g.fillOval(750,450,10,10); g.drawLine(805,355,755,455); stop(); g.fillOval(870,450,10,10); g.drawLine(805,355,875,455); stop(); g.drawString((String)keystructureName.get("4"),860,450); g.drawString("I="+keystructureKey.get("4"),860,460); stop(); g.drawString((String)keystructureName.get("8"),810,450); g.drawString("I="+keystructureKey.get("8"),810,460); stop(); g.drawString("S="+subkey.get("6"),740,360); stop(); g.drawString("S="+subkey.get("2"),640,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160); } }//GEN-LAST:event_TreeActionPerformed private void StopServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StopServerActionPerformed System.out.println("Inside the Stop Server"); StartServer.enable(true); Start=false; }//GEN-LAST:event_StopServerActionPerformed private void StartServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartServerActionPerformed System.out.println("Inside the StartServer Method"); Start=true; StartServer.enable(false); System.out.println("Inside the TreeForamDraw Method"); JOptionPane.showMessageDialog(null,"Server is Started"); try { new Thread(this).start(); } catch(Exception e) { System.out.println("Error in Thread Start:"+e); } }//GEN-LAST:event_StartServerActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { new KeyServer().show(); } public void run() { System.out.println("Inside the Run Method"); Vector ServerData=new Vector(); while(Start){ try{ System.out.println("The Server is waiting For Client Request"); clientValue=GroupKeyServer.accept(); ServerData.removeAllElements(); ObjectInputStream OIS=new ObjectInputStream(clientValue.getInputStream()); Vector clientDetails=(Vector)OIS.readObject(); System.out.println("The Server Receive Data from Client is:"+clientDetails); String Root=(String)clientDetails.elementAt(0); if(Root.equalsIgnoreCase("MemberJoin")){ System.out.println("Inside the MemberJoin Loop"); StoreKeyValue(clientDetails); ServerData=KeyGenerate(clientDetails); Tree.doClick(); GroupList.setListData(GroupMemberName); ServerData.addElement(GroupMemberName); }else if(Root.equalsIgnoreCase("MemberRemove")){ System.out.println("Inside the MemberRemove part"); RemoveValue(clientDetails); GroupList.setListData(GroupMemberName); ServerData.addElement("Success"); ServerData.addElement(TotalGroupKey); ServerData.addElement(GroupMemberName); } else{ System.out.println("Inside the else part"); } ObjectOutputStream OOS=new ObjectOutputStream(clientValue.getOutputStream()); System.out.println("Server output is:"+ServerData); OOS.writeObject(ServerData); OOS.flush(); OOS.close(); }catch(Exception e){ System.out.println("The client request procession error:"+e); ServerData.addElement("Fail"); ServerData.addElement(e.toString()); try{ ObjectOutputStream OOS=new ObjectOutputStream(clientValue.getOutputStream()); System.out.println("Server output is:"+ServerData); OOS.writeObject(ServerData); OOS.flush(); OOS.close(); }catch(Exception e1){ System.out.println("The error from sending error"+e1); } } } } public void StoreKeyValue(Vector clientDetails){ System.out.println("Inside the Store Key Method"); String UserName=(String)clientDetails.elementAt(1); BigInteger IKey=(BigInteger)clientDetails.elementAt(2); GroupMemberName.addElement(UserName); GroupMemberIKey.put(UserName,IKey); GMIDDetails.put(String.valueOf(membercount),UserName); membercount++; System.out.println("Stored Value are:\n"); System.out.println("The GroupMemberName Vector Value is:"+GroupMemberName); System.out.println("Group MemberIndividual Key is:"+GroupMemberIKey); System.out.println("Group Member Identificatio Number and Group Name is:"+GMIDDetails); } public void RemoveValue(Vector clientDetails){ System.out.println("Inside the RemoveValue Method"); String MemberName=(String)clientDetails.elementAt(1); GroupMemberName.remove(MemberName); GroupMemberIKey.remove(MemberName); /*System.out.println("inside the size 4"); BigInteger t1=(BigInteger)subkey.get("5"); BigInteger t2=(BigInteger)keystructureKey.get("4"); System.out.println("inside the size 4.1"); BigInteger tmp1=keycreate(t1,t2); System.out.println("inside the size 4.2"+tmp1); subkey.put("2",tmp1); System.out.println("inside the size 4.2"); t1=tmp1; t2=(BigInteger)subkey.get("1"); System.out.println("inside the size 4.2"); tmp1=keycreate(t1,t2); System.out.println("inside the size 4.2"); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey);*/ /* Graphics g=getGraphics(); g.setColor(new Color(204,204,204)); g.drawString((String)keystructureName.get("4"),860,450); g.drawString("I="+keystructureKey.get("4"),860,460); g.drawString((String)keystructureName.get("8"),810,450); g.drawString("I="+keystructureKey.get("8"),810,460); g.drawString("S="+subkey.get("6"),740,360); g.drawString("S= ",640,260); g.drawString("G= ",515,160); g.fillOval(750,450,10,10); g.drawLine(805,355,755,455); g.fillOval(870,450,10,10); g.drawLine(805,355,875,455); g.drawString("S="+subkey.get("2"),640,260); g.drawString("G="+keystructureKey.get("0"),515,160); g.setColor(new Color(40,40,40)); g.fillOval(750,450,10,10); g.drawLine(805,355,755,455); g.drawString((String)keystructureName.get("4"),840,450); g.drawString("I="+keystructureKey.get("4"),840,460); stop(); subkey.put("6",keystructureKey.get("4")); g.drawString("S="+subkey.get("6"),740,360); stop(); g.drawString("S="+subkey.get("2"),640,260); stop(); g.drawString("G="+keystructureKey.get("0"),515,160);*/ } public Vector KeyGenerate(Vector clientDetails){ System.out.println("Inside the KeyGeneration Method"); int size=GroupMemberName.size(); System.out.println("Number of GroupMember is:"+size); Vector coll=new Vector(); if(size==1){ System.out.println("inside the size 1"); TotalGroupKey=new BigInteger("0"); FreeMemberCount=1; keystructureKey.put("0",TotalGroupKey); keystructureName.put("1",clientDetails.elementAt(1)); keystructureKey.put("1",clientDetails.elementAt(2)); } else if(size==2){ System.out.println("inside the size 2"); keystructureName.put("2",clientDetails.elementAt(1)); keystructureKey.put("2",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("1"); BigInteger t2=(BigInteger)keystructureKey.get("2"); BigInteger tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); } else if(size==3){ System.out.println("inside the size 3"); keystructureName.put("3",clientDetails.elementAt(1)); keystructureKey.put("3",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("1"); BigInteger t2=(BigInteger)keystructureKey.get("3"); BigInteger tmp1=keycreate(t1,t2); subkey.put("1",tmp1); t1=tmp1; t2=(BigInteger)keystructureKey.get("2"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); }else if(size==4){ System.out.println("inside the size 4"); keystructureName.put("4",clientDetails.elementAt(1)); keystructureKey.put("4",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("2"); BigInteger t2=(BigInteger)keystructureKey.get("4"); BigInteger tmp1=keycreate(t1,t2); subkey.put("2",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("1"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); }else if(size==5){ System.out.println("inside the size 5"); keystructureName.put("5",clientDetails.elementAt(1)); keystructureKey.put("5",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("1"); BigInteger t2=(BigInteger)keystructureKey.get("5"); BigInteger tmp1=keycreate(t1,t2); subkey.put("3",tmp1); t1=tmp1; t2=(BigInteger)keystructureKey.get("3"); tmp1=keycreate(t1,t2); subkey.put("1",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("2"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); }else if(size==6){ System.out.println("inside the size 6"); keystructureName.put("6",clientDetails.elementAt(1)); keystructureKey.put("6",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("3"); BigInteger t2=(BigInteger)keystructureKey.get("6"); BigInteger tmp1=keycreate(t1,t2); subkey.put("4",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("3"); tmp1=keycreate(t1,t2); subkey.put("1",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("2"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); }else if(size==7){ System.out.println("inside the size 7"); keystructureName.put("7",clientDetails.elementAt(1)); keystructureKey.put("7",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("2"); BigInteger t2=(BigInteger)keystructureKey.get("7"); BigInteger tmp1=keycreate(t1,t2); subkey.put("5",tmp1); t1=tmp1; t2=(BigInteger)keystructureKey.get("4"); tmp1=keycreate(t1,t2); subkey.put("2",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("1"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); }else if(size==8){ System.out.println("inside the size 8"); keystructureName.put("8",clientDetails.elementAt(1)); keystructureKey.put("8",clientDetails.elementAt(2)); BigInteger t1=(BigInteger)keystructureKey.get("4"); BigInteger t2=(BigInteger)keystructureKey.get("8"); BigInteger tmp1=keycreate(t1,t2); subkey.put("6",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("5"); tmp1=keycreate(t1,t2); subkey.put("2",tmp1); t1=tmp1; t2=(BigInteger)subkey.get("1"); tmp1=keycreate(t1,t2); TotalGroupKey=tmp1; keystructureKey.put("0",TotalGroupKey); } coll.addElement("Success"); coll.addElement(TotalGroupKey); return coll; } public BigInteger keycreate(BigInteger u1,BigInteger u2){ BigInteger YaU1=GRNO.modPow(u1,PrimeNo); BigInteger YbU2=GRNO.modPow(u2,PrimeNo); //create the Group Key BigInteger A=YbU2.modPow(u1,PrimeNo); BigInteger B=YaU1.modPow(u2,PrimeNo); //Verify the groupKey are Equal if(A.equals(B)){ System.out.println("The Key are Equal"); }else{ System.out.println("The Keys are Not Equal"); } return A; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton Exit; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JButton StopServer; private javax.swing.JButton Tree; private javax.swing.JButton StartServer; private javax.swing.JList GroupList; // End of variables declaration//GEN-END:variables }

Sample ScreenShot:

SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑
bottom