Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------------CA-------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import javax.swing.JFrame;
- /**
- *
- * @author ali
- */
- public class CA extends javax.swing.JFrame {
- /**
- * Creates new form CA
- */
- public CA() {
- initComponents();
- this.getContentPane().setBackground(Color.gray);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("Central_Authority");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jLabel2 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(0, 102, 0));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jButton1.setBackground(new java.awt.Color(255, 0, 0));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(255, 255, 255));
- jButton1.setText("REVOCATION USERS");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setBackground(new java.awt.Color(102, 0, 102));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton2.setText("SECRET CHANNEL");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/per.jpg"))); // NOI18N
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(31, 31, 31)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel1)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(82, 82, 82)
- .addComponent(jLabel2)
- .addGap(18, 18, 18)))
- .addContainerGap(57, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addComponent(jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(67, 67, 67)
- .addComponent(jButton1)
- .addGap(49, 49, 49)
- .addComponent(jButton2))
- .addGroup(layout.createSequentialGroup()
- .addGap(31, 31, 31)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(74, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here
- Revocation r=new Revocation();
- r.setVisible(true);
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here:
- CAaccept ca=new CAaccept();
- ca.setVisible(true);
- }//GEN-LAST:event_jButton2ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new CA().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------CA LOGIN-------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class CAlogin extends javax.swing.JFrame {
- /**
- * Creates new form CAlogin
- */
- public CAlogin() {
- initComponents();
- this.getContentPane().setBackground(Color.PINK);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("Central_Authority_Login");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jButton1 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jLabel4 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(51, 0, 204));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel2.setText("Username");
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setText("Password");
- jTextField1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jTextField1ActionPerformed(evt);
- }
- });
- jButton1.setBackground(new java.awt.Color(0, 0, 153));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(255, 255, 255));
- jButton1.setText("Login");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/a.jpg"))); // NOI18N
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(42, 42, 42)
- .addComponent(jLabel1)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(232, 232, 232)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(80, 80, 80)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jLabel3))
- .addGap(77, 77, 77)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel4)
- .addGap(20, 20, 20))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(34, 34, 34)
- .addComponent(jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addGap(41, 41, 41))
- .addGroup(layout.createSequentialGroup()
- .addGap(66, 66, 66)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)))
- .addComponent(jButton1)
- .addGap(49, 49, 49))
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel4)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jTextField1ActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- if(jTextField1.getText().equals("CA") && jPasswordField1.getText().equals("CA") )
- {
- CA c=new CA();
- c.setVisible(true);
- dispose();
- }
- else{
- JOptionPane.showMessageDialog(null,"Incorrect either Username or Password","ERROR",JOptionPane.ERROR_MESSAGE);
- }
- }//GEN-LAST:event_jButton1ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new CAlogin().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------HOME-------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- /**
- *
- * @author ali
- */
- public class Home extends javax.swing.JFrame {
- /**
- * Creates new form Home
- */
- public Home() {
- initComponents();
- this.getContentPane().setBackground(Color.ORANGE);
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jLabel3 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setForeground(new java.awt.Color(0, 51, 255));
- getContentPane().setLayout(new java.awt.GridBagLayout());
- jButton1.setText("Sender");
- getContentPane().add(jButton1, new java.awt.GridBagConstraints());
- jButton2.setText("Users");
- getContentPane().add(jButton2, new java.awt.GridBagConstraints());
- jButton3.setText("Key authorities");
- getContentPane().add(jButton3, new java.awt.GridBagConstraints());
- jLabel3.setBackground(new java.awt.Color(51, 51, 0));
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(0, 102, 0));
- jLabel3.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- getContentPane().add(jLabel3, new java.awt.GridBagConstraints());
- pack();
- }// </editor-fold>//GEN-END:initComponents
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Home().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JLabel jLabel3;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------KEY AUTHORITY HOME---------------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.security.Key;
- import java.security.Security;
- import javax.crypto.Cipher;
- import javax.crypto.KeyGenerator;
- import java.awt.Color;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.crypto.KeyGenerator;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class KeyAuthorHome extends javax.swing.JFrame {
- /**
- * Creates new form KeyAuthorHome
- */
- String unm, batalion,unm1,eid,b,r;
- ResultSet r1=null;
- public KeyAuthorHome(String unm) {
- initComponents();
- this.getContentPane().setBackground(Color.orange);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("KeyAuthority-Home");
- this.setResizable(false);
- this.unm=unm;
- }
- /**r
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jInternalFrame1 = new javax.swing.JInternalFrame();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jButton1 = new javax.swing.JButton();
- jPanel1 = new javax.swing.JPanel();
- jTextField2 = new javax.swing.JTextField();
- jTextField5 = new javax.swing.JTextField();
- jTextField3 = new javax.swing.JTextField();
- jTextField4 = new javax.swing.JTextField();
- jButton2 = new javax.swing.JButton();
- jLabel3 = new javax.swing.JLabel();
- jButton3 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jButton4 = new javax.swing.JButton();
- jInternalFrame1.setVisible(true);
- javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
- jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
- jInternalFrame1Layout.setHorizontalGroup(
- jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 0, Short.MAX_VALUE)
- );
- jInternalFrame1Layout.setVerticalGroup(
- jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 0, Short.MAX_VALUE)
- );
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(204, 0, 153));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(51, 51, 0));
- jLabel2.setText("Enter Username");
- jButton1.setBackground(new java.awt.Color(153, 153, 0));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton1.setForeground(new java.awt.Color(51, 0, 0));
- jButton1.setText("Request Details");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Public Parameters", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 12), new java.awt.Color(51, 51, 0))); // NOI18N
- jTextField2.setEditable(false);
- jTextField2.setBorder(null);
- jTextField5.setEditable(false);
- jTextField5.setBorder(null);
- jTextField3.setEditable(false);
- jTextField3.setBorder(null);
- jTextField3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jTextField3ActionPerformed(evt);
- }
- });
- jTextField4.setEditable(false);
- jTextField4.setBorder(null);
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jTextField2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
- .addComponent(jTextField2)
- .addComponent(jTextField4)
- .addComponent(jTextField5))
- .addContainerGap())
- );
- jButton2.setBackground(new java.awt.Color(255, 51, 153));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton2.setForeground(new java.awt.Color(0, 0, 255));
- jButton2.setText("GetParameters");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(153, 0, 0));
- jLabel3.setText("Secret Key");
- jButton3.setBackground(new java.awt.Color(0, 204, 204));
- jButton3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton3.setForeground(new java.awt.Color(51, 0, 51));
- jButton3.setText("GenerateKey");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jPasswordField1.setEditable(false);
- jButton4.setBackground(new java.awt.Color(51, 153, 0));
- jButton4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton4.setForeground(new java.awt.Color(255, 255, 255));
- jButton4.setText("SEND");
- jButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton4ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(46, 46, 46)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel1)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton2)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(34, 34, 34)
- .addComponent(jButton1))))))
- .addGroup(layout.createSequentialGroup()
- .addGap(47, 47, 47)
- .addComponent(jLabel3)
- .addGap(19, 19, 19)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jButton3))
- .addGroup(layout.createSequentialGroup()
- .addGap(146, 146, 146)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(0, 68, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(23, 23, 23)
- .addComponent(jLabel1)
- .addGap(56, 56, 56)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton1))
- .addGap(28, 28, 28)
- .addComponent(jButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(34, 34, 34)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton3))
- .addGap(18, 18, 18)
- .addComponent(jButton4)
- .addContainerGap(53, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- try{
- Connection con=database.getConnection();
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- ResultSet r=st.executeQuery("select batalion from keysignup where unm='"+unm+"'");
- if(r.next()){
- batalion=r.getString(1);
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- UserDetails frame=new UserDetails(unm,batalion);
- frame.pack();
- frame.setVisible(true);
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here:
- String unm=jTextField1.getText();
- try{
- Connection con=database.getConnection();
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- r1=st.executeQuery("select *from signup where unm='"+unm+"'");
- if(r1.next())
- {
- unm1=r1.getString(1);
- jTextField2.setText(r1.getString(1));
- eid=r1.getString(3);
- jTextField3.setText(r1.getString(3));
- b=r1.getString(4);
- jTextField4.setText(r1.getString(4));
- r=r1.getString(5);
- jTextField5.setText(r1.getString(5));
- }
- }catch(Exception e){ e.printStackTrace();}
- }//GEN-LAST:event_jButton2ActionPerformed
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
- // TODO add your handling code here:
- try{
- KeyGenerator KeyGen = KeyGenerator.getInstance("AES");
- KeyGen.init(256);
- Key wrapKey = KeyGen.generateKey();
- System.out.println("key="+((wrapKey.toString()).getBytes()).toString());
- jPasswordField1.setText(((wrapKey.toString()).getBytes()).toString());
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton3ActionPerformed
- private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
- // TODO add your handling code here:
- SendKey sk=new SendKey();
- sk.setKey(jPasswordField1.getText());
- try{
- Connection con1=database.getConnection();
- Statement st2=con1.createStatement();
- Statement st3=con1.createStatement();
- int i=st3.executeUpdate("delete from key_");
- System.out.println(i);
- int r2=st2.executeUpdate("insert into key_ values('"+jPasswordField1.getText()+"')");
- if(r2==1)
- JOptionPane.showMessageDialog(null,"Secret-Key Sent to Sender Successfully");
- dispose();
- }catch(Exception e){
- e.printStackTrace();
- }
- // System.out.println("sk="+sk.getKey());
- }//GEN-LAST:event_jButton4ActionPerformed
- private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jTextField3ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>//
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new KeyAuthorHome("a").setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JInternalFrame jInternalFrame1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JTextField jTextField2;
- private javax.swing.JTextField jTextField3;
- private javax.swing.JTextField jTextField4;
- private javax.swing.JTextField jTextField5;
- // End of variables declaration//GEN-END:variables
- }
- ---------------------------------------------------------KEY AUTHORITY LOGIN----------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.net.CacheResponse;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class KeyAuthorLogin extends javax.swing.JFrame {
- /**
- * Creates new form KeyAuthorLogin
- */
- public KeyAuthorLogin() {
- initComponents();
- this.getContentPane().setBackground(Color.MAGENTA);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("KeyAuhority-Login");
- this.setResizable(false);
- }
- /**
- * This method is called from within the construc
- * tor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jLabel4 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(51, 51, 0));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(0, 51, 51));
- jLabel2.setText("Username");
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(51, 51, 51));
- jLabel3.setText("Password");
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton1.setForeground(new java.awt.Color(204, 102, 0));
- jButton1.setText("Login");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton2.setForeground(new java.awt.Color(0, 102, 102));
- jButton2.setText("NewUser");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jPasswordField1ActionPerformed(evt);
- }
- });
- jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/l1.jpg"))); // NOI18N
- jLabel4.setText("jLabel4");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addContainerGap())
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(45, 45, 45)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(148, 148, 148)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel3)
- .addGap(18, 18, 18)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(63, 63, 63))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jButton2)
- .addGap(119, 119, 119))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(41, 41, 41)
- .addComponent(jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(66, 66, 66)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addGap(61, 61, 61)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addGap(40, 40, 40))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton2)
- .addComponent(jButton1))
- .addContainerGap(87, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- String unm=jTextField1.getText();
- String pwd=jPasswordField1.getText();
- try{
- Connection con=database.getConnection();
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- ResultSet r=st.executeQuery("select *from keysignup where unm='"+unm+"' and pwd='"+pwd+"'");
- if(r.next())
- {
- ResultSet r1=st.executeQuery("select *from keysignup where unm='"+unm+"' and status='Not-Accepted'");
- if(r1.next())
- {
- JOptionPane.showMessageDialog(null,"Your Request is Under the Process...");
- }
- else{
- KeyAuthorHome kah=new KeyAuthorHome(unm);
- kah.setVisible(true);
- dispose();
- }
- }else{
- JOptionPane.showMessageDialog(null,"Incorrect Either Username or Password", "Error",JOptionPane.ERROR_MESSAGE);
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here
- KeyAuthorReg kreg=new KeyAuthorReg();
- kreg.setVisible(true);
- }//GEN-LAST:event_jButton2ActionPerformed
- private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jPasswordField1ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new KeyAuthorLogin().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------KEY AUTHORITY REGISTRATION-------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class KeyAuthorReg extends javax.swing.JFrame {
- /**
- * Creates new form KeyAuthorReg
- */
- public KeyAuthorReg() {
- initComponents();
- this.getContentPane().setBackground(Color.yellow);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("KeyAuthority-Registration");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jTextField2 = new javax.swing.JTextField();
- jLabel5 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jComboBox1 = new javax.swing.JComboBox();
- jLabel6 = new javax.swing.JLabel();
- jLabel7 = new javax.swing.JLabel();
- jPasswordField1 = new javax.swing.JPasswordField();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel2.setText("Username");
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel3.setText("Email-Id");
- jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel4.setText("Battalion");
- jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jLabel5.setText("Password");
- jButton1.setBackground(new java.awt.Color(0, 153, 102));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton1.setForeground(new java.awt.Color(0, 102, 102));
- jButton1.setText("Submit");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "B1", "B2" }));
- jComboBox1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox1ActionPerformed(evt);
- }
- });
- jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/key.jpg"))); // NOI18N
- jLabel7.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
- jLabel7.setForeground(new java.awt.Color(102, 0, 102));
- jLabel7.setText("Key-Authority Registration");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(79, 79, 79)
- .addComponent(jLabel1)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(55, 55, 55)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel7)
- .addGroup(layout.createSequentialGroup()
- .addGap(45, 45, 45)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel5)
- .addComponent(jLabel2)
- .addComponent(jLabel3)
- .addComponent(jLabel4))))
- .addGap(30, 30, 30)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jTextField1)
- .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 4, Short.MAX_VALUE))
- .addComponent(jPasswordField1))
- .addGap(51, 51, 51)
- .addComponent(jLabel6)
- .addGap(25, 25, 25))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
- .addComponent(jLabel7)
- .addGap(32, 32, 32)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel6)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addGap(31, 31, 31)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel5)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(32, 32, 32)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addGap(28, 28, 28)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel4)
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(31, 31, 31)
- .addComponent(jButton1)))
- .addGap(88, 88, 88))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- String unm=jTextField1.getText();
- String pwd=jPasswordField1.getText();
- String eid=jTextField2.getText();
- String b= jComboBox1.getSelectedItem().toString();
- try{
- Connection con=database.getConnection();
- PreparedStatement pst=con.prepareStatement("insert into keysignup values(?,?,?,?,?)");
- pst.setString(1,unm);
- pst.setString(2,pwd);
- pst.setString(3,eid);
- pst.setString(4,b);
- pst.setString(5,"Not-Accepted");
- int i=pst.executeUpdate();
- if(i==1){
- JOptionPane.showMessageDialog(null,"Key-Authority Registerd Successfully");
- }
- dispose();
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jComboBox1ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new KeyAuthorReg().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JTextField jTextField2;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------MAIN-----------------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import javax.swing.JFrame;
- /**
- *
- * @author ali
- */
- public class Main extends javax.swing.JFrame {
- /**
- * Creates new form Main
- */
- public Main() {
- initComponents();
- this.setTitle("CP-ABE FOR SECURE DATA");
- this.setResizable(false);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.getContentPane().setBackground(Color.orange);
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel2 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jPanel1 = new javax.swing.JPanel();
- jLabel1 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/arc.png"))); // NOI18N
- jButton1.setBackground(new java.awt.Color(0, 153, 0));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(255, 153, 255));
- jButton1.setText("Sender");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setBackground(new java.awt.Color(0, 102, 102));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton2.setForeground(new java.awt.Color(51, 51, 0));
- jButton2.setText("Users");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton3.setBackground(new java.awt.Color(255, 51, 255));
- jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton3.setForeground(new java.awt.Color(0, 51, 204));
- jButton3.setText("Key Authority");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jLabel1.setBackground(new java.awt.Color(0, 0, 204));
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(51, 51, 0));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addContainerGap())
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addContainerGap())
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(45, 45, 45)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(7, 7, 7)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(25, 25, 25))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(36, 36, 36)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(113, 113, 113)
- .addComponent(jButton1)
- .addGap(64, 64, 64)
- .addComponent(jButton2)
- .addGap(63, 63, 63)
- .addComponent(jButton3))
- .addGroup(layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(46, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- Sender s=new Sender();
- s.setVisible(true);
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
- // TODO add your handling code here:
- KeyAuthorLogin kl=new KeyAuthorLogin();
- kl.setVisible(true);
- }//GEN-LAST:event_jButton3ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here:
- User_Login ul=new User_Login();
- ul.setVisible(true);
- }//GEN-LAST:event_jButton2ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Main().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPanel jPanel1;
- // End of variables declaration//GEN-END:variables
- }
- ------------------------------------------------------SENDER---------------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.awt.FileDialog;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.border.Border;
- import javax.swing.border.LineBorder;
- import javax.swing.border.TitledBorder;
- /**
- *
- * @author ali
- */
- public class Sender extends javax.swing.JFrame {
- /**
- * Creates new form DataUploading
- */
- String filesel,f4;
- public Sender() {
- initComponents();
- this.getContentPane().setBackground(Color.green);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- Border thickBorder = new LineBorder(Color.WHITE, 2);
- JLabel titb=new JLabel();
- TitledBorder titled = new TitledBorder("sensor1 Monitor");
- titb.setBorder(thickBorder);
- this.setTitle("Sender");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jTextField2 = new javax.swing.JTextField();
- jButton2 = new javax.swing.JButton();
- jButton1 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jPanel1 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jLabel3 = new javax.swing.JLabel();
- jButton4 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setBackground(new java.awt.Color(255, 0, 0));
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(0, 0, 102));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel2.setText("Choose File");
- jButton2.setBackground(new java.awt.Color(204, 204, 255));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton2.setForeground(new java.awt.Color(0, 0, 204));
- jButton2.setText("Browse");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton1.setBackground(new java.awt.Color(102, 0, 204));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(255, 255, 0));
- jButton1.setText("Requested Key");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton3.setBackground(new java.awt.Color(0, 102, 102));
- jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton3.setForeground(new java.awt.Color(0, 255, 153));
- jButton3.setText("Get-Key");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "File Data", 0, 0, new java.awt.Font("Times New Roman", 1, 12), new java.awt.Color(0, 0, 204))); // NOI18N
- jScrollPane1.setViewportView(jTextArea1);
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGap(19, 19, 19)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, Short.MAX_VALUE))
- );
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setText("Public Key");
- jButton4.setBackground(new java.awt.Color(153, 255, 153));
- jButton4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton4.setForeground(new java.awt.Color(0, 153, 153));
- jButton4.setText("Encrypt-Data");
- jButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton4ActionPerformed(evt);
- }
- });
- jPasswordField1.setEditable(false);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGap(42, 42, 42)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addGap(143, 143, 143)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(55, 55, 55)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .addGroup(layout.createSequentialGroup()
- .addGap(158, 158, 158)
- .addComponent(jLabel3)
- .addGap(27, 27, 27)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(33, 33, 33)
- .addComponent(jButton4))
- .addGroup(layout.createSequentialGroup()
- .addGap(57, 57, 57)
- .addComponent(jLabel1)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(40, 40, 40)
- .addComponent(jLabel1)
- .addGap(50, 50, 50)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton2))
- .addGap(35, 35, 35)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(66, 66, 66)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(48, 48, 48)
- .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(43, 43, 43))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
- // TODO add your handling code here:
- try{
- Connection con=database.getConnection();
- PreparedStatement pst=con.prepareStatement("select *from key_");
- ResultSet r=pst.executeQuery();
- if(r.next()){
- System.out.println(r.getString(1));
- jPasswordField1.setText(r.getString(1));
- }
- // dispose();
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton3ActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- RequestedKey rk=new RequestedKey();
- rk.setVisible(true);
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here:
- File f=null;
- String st=null;
- FileInputStream fin=null,files=null;
- FileDialog fd1=new FileDialog(this,"OPEN",FileDialog.LOAD);
- fd1.setVisible(true);
- f4=fd1.getFile();
- filesel=fd1.getDirectory()+fd1.getFile();
- jTextField2.setText(filesel);
- try{
- f=new File(filesel);
- int sz,sz1;
- byte[] buffer;
- fin=new FileInputStream(filesel);
- int filesize=fin.available();
- buffer=new byte[filesize];
- for(int i=0;i<7;i++)
- {
- fin.read(buffer);
- st=new String(buffer);
- }
- jTextArea1.append(st);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton2ActionPerformed
- private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
- // TODO add your handling code here:
- try{ File f1=new File(filesel);
- FileInputStream files=new FileInputStream(filesel);
- Connection con=database.getConnection();
- PreparedStatement pst=con.prepareStatement("insert into storenode(fname,fdata,keyss) values(?,AES_ENCRYPT(?,'"+jPasswordField1.getText()+"'),'"+jPasswordField1.getText()+"')");
- pst.setString(1,f4);
- pst.setBinaryStream(2,(InputStream)files,(int)(f1.length()));
- int r=pst.executeUpdate();
- if(r==1){
- System.out.println(r);
- EncryptData en=new EncryptData(f4);
- en.setVisible(true);
- dispose();
- }
- // dispose();
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton4ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Sender().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextArea jTextArea1;
- private javax.swing.JTextField jTextField2;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------STORAGE NODE-----------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import javax.swing.JFrame;
- /**
- *
- * @author ali
- */
- public class StorageNode extends javax.swing.JFrame {
- /**
- * Creates new form StorageNode
- */
- public StorageNode() {
- initComponents();
- this.getContentPane().setBackground(Color.yellow);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("Storage_Node");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(51, 51, 0));
- jLabel2.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jButton1.setBackground(new java.awt.Color(51, 51, 0));
- jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/node.png"))); // NOI18N
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(221, 221, 221)
- .addComponent(jLabel1))
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addComponent(jLabel2))
- .addGroup(layout.createSequentialGroup()
- .addGap(135, 135, 135)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(39, 39, 39)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel1)
- .addGap(18, 18, 18)
- .addComponent(jButton1)
- .addContainerGap(73, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- FilesDetails f=new FilesDetails();
- f.pack();
- f.setVisible(true);
- }//GEN-LAST:event_jButton1ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new StorageNode().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- // End of variables declaration//GEN-END:variables
- }
- -----------------------------------------------------USER HOME----------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.swing.DefaultListModel;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class User_Home extends javax.swing.JFrame {
- /**
- * Creates new form User_Home
- */ byte b[];
- String skey=null;
- String fname=null;
- String unm=null;
- public User_Home(String unm) {
- initComponents();
- this.getContentPane().setBackground(Color.CYAN);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("User-Home");
- this.setResizable(false);
- this.unm=unm;
- DefaultListModel dlm=new DefaultListModel();
- try{
- Connection con=database.getConnection();
- Statement st=con.createStatement();
- Statement st1=con.createStatement();Statement st2=con.createStatement();
- String aces="";
- ResultSet r2=st2.executeQuery("select access from signup where unm='"+unm+"'");
- if(r2.next())
- {
- aces=r2.getString(1);
- }
- ResultSet r=st.executeQuery("select fname,access from storenode");
- while(r.next())
- {
- String a=String.valueOf(aces.charAt(0))+String.valueOf(aces.charAt(1));
- String b=String.valueOf(r.getString(2).charAt(0))+String.valueOf(r.getString(2).charAt(1));
- System.out.println("a="+String.valueOf(aces.charAt(0)));
- System.out.println("b="+String.valueOf(r.getString(2).charAt(0)));
- if(a.equals(b)){
- dlm.addElement(r.getString(1));
- }
- }
- jList1.setModel(dlm);
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jList1 = new javax.swing.JList();
- jButton1 = new javax.swing.JButton();
- jScrollPane2 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jLabel2 = new javax.swing.JLabel();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jButton4 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(255, 51, 0));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jList1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Available Files", 0, 0, new java.awt.Font("Times New Roman", 1, 12), new java.awt.Color(51, 51, 0))); // NOI18N
- jList1.setModel(new javax.swing.AbstractListModel() {
- String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
- public int getSize() { return strings.length; }
- public Object getElementAt(int i) { return strings[i]; }
- });
- jScrollPane1.setViewportView(jList1);
- jButton1.setBackground(new java.awt.Color(51, 204, 0));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(102, 102, 102));
- jButton1.setText("View");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jTextArea1.setEditable(false);
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jScrollPane2.setViewportView(jTextArea1);
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel2.setText("SecretKey");
- jButton2.setBackground(new java.awt.Color(204, 51, 0));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton2.setText("GetKey");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton3.setBackground(new java.awt.Color(51, 51, 51));
- jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton3.setText("Decrypt-Data");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jPasswordField1.setEditable(false);
- jButton4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pr1.png"))); // NOI18N
- jButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton4ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButton3)
- .addGap(208, 208, 208))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel2)
- .addGap(18, 18, 18)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jButton2)
- .addGap(75, 75, 75))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(47, 47, 47)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(38, 38, 38))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(31, 31, 31)))
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 370, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(22, 22, 22)
- .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE)
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(37, 37, 37)
- .addComponent(jLabel1)
- .addGap(48, 48, 48)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(34, 34, 34))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(31, 31, 31)))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1)
- .addComponent(jButton2)
- .addComponent(jLabel2)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addComponent(jButton3)
- .addContainerGap(47, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- String b1,r1,aces=null;
- fname= (String) jList1.getSelectedValue();
- // System.out.print(s);
- try{
- Connection con1=database.getConnection();
- Statement st1=con1.createStatement();
- Statement st2=con1.createStatement();
- ResultSet r2=st2.executeQuery("select access from signup where unm='"+unm+"'");
- if(r2.next()){
- aces=r2.getString(1);
- }
- Statement s3=con1.createStatement();
- ResultSet rs4=s3.executeQuery("select *from signup where unm='"+unm+"' and status='Revoked'");
- if(!(rs4.next()))
- {
- Statement st3=con1.createStatement();
- ResultSet r4=st3.executeQuery("select *from storenode where fname='"+fname+"' and access='"+aces+"'");
- if(r4.next())
- {
- ResultSet r3=st1.executeQuery("select fdata from storenode where fname='"+fname+"'");
- while(r3.next())
- {
- b=r3.getBytes(1);
- }
- String data=new String(b);
- jTextArea1.setText("");
- jTextArea1.append(data);
- }
- else{
- JOptionPane.showMessageDialog(null,"You Can not Access this File","Warning",JOptionPane.WARNING_MESSAGE);
- }
- }
- else{
- JOptionPane.showMessageDialog(null,"Your Revoked and You Can not Access this File","Warning",JOptionPane.WARNING_MESSAGE);
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- try{
- Connection con1=database.getConnection();
- Statement st1=con1.createStatement();
- if(jTextArea1.getText().equals("")){
- JOptionPane.showMessageDialog(null,"Please First View the File");
- }else{
- ResultSet r1=st1.executeQuery("select keyss from storenode where fname='"+fname+"'");
- if(r1.next())
- {
- skey=r1.getString(1);
- jPasswordField1.setText(skey);
- }
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton2ActionPerformed
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
- // TODO add your handling code here:
- try{
- Connection con1=database.getConnection();
- Statement st1=con1.createStatement();
- if(jPasswordField1.getText().equals("")){
- JOptionPane.showMessageDialog(null,"Please Enter Key");
- }else{
- ResultSet r1=st1.executeQuery("select AES_DECRYPT(fdata,'"+jPasswordField1.getText()+"')from storenode where fname='"+fname+"'");
- System.out.println("r1="+r1);
- if(r1.next())
- {
- System.out.print("k2");
- b=r1.getBytes(1);
- if(b==null)
- {
- JOptionPane.showMessageDialog(null,
- "Please Enter Valid Secret-Key",
- "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- else{
- DecryptData dd=new DecryptData(fname,jPasswordField1.getText());
- dd.setVisible(true);
- }
- }
- }}
- catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton3ActionPerformed
- private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
- // TODO add your handling code here:
- Profile frame= new Profile(unm);
- frame.pack();
- frame.setVisible(true);
- }//GEN-LAST:event_jButton4ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new User_Home("k").setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JList jList1;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JTextArea jTextArea1;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------USER LOGIN----------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.awt.Panel;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class User_Login extends javax.swing.JFrame {
- /**
- * Creates new form User_Home
- */
- public User_Login () {
- initComponents();
- this.getContentPane().setBackground(Color.PINK);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("User-Login");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jMenuItem1 = new javax.swing.JMenuItem();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jLabel3 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jLabel4 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- jMenuItem1.setText("jMenuItem1");
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setBackground(new java.awt.Color(102, 0, 102));
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(51, 51, 0));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(0, 0, 153));
- jLabel2.setText("Usename");
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(0, 0, 153));
- jLabel3.setText("Password");
- jButton1.setBackground(new java.awt.Color(0, 102, 0));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton1.setForeground(new java.awt.Color(255, 255, 255));
- jButton1.setText("Login");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setBackground(new java.awt.Color(153, 51, 0));
- jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jButton2.setForeground(new java.awt.Color(0, 0, 51));
- jButton2.setText("NewUser");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/lgn.jpg"))); // NOI18N
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addComponent(jLabel1))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(52, 52, 52)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jLabel3))
- .addGap(45, 45, 45)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
- .addComponent(jPasswordField1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(90, 90, 90)))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(100, 100, 100)))))
- .addContainerGap(19, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(28, 28, 28)
- .addComponent(jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(81, 81, 81)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(60, 60, 60)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel3)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createSequentialGroup()
- .addGap(50, 50, 50)
- .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addComponent(jButton2))
- .addGroup(layout.createSequentialGroup()
- .addGap(4, 4, 4)
- .addComponent(jButton1)))
- .addContainerGap(69, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- String unm=jTextField1.getText();
- String pwd=jPasswordField1.getText();
- try{
- Connection con=database.getConnection();
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- ResultSet r=st.executeQuery("select *from signup where unm='"+unm+"' and pwd='"+pwd+"'");
- if(r.next())
- {
- User_Home uhm=new User_Home(unm);
- uhm.setVisible(true);
- dispose();
- }
- else{
- JOptionPane.showMessageDialog(null,"Incorrect either Username or Password","Error",JOptionPane.ERROR_MESSAGE);
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
- // TODO add your handling code here:
- User_Reg ureg=new User_Reg();
- ureg.setVisible(true);
- }//GEN-LAST:event_jButton2ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new User_Login().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JMenuItem jMenuItem1;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration//GEN-END:variables
- }
- ---------------------------------------------------USER REGISTRATION---------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- import java.awt.Color;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- /**
- *
- * @author ali
- */
- public class User_Reg extends javax.swing.JFrame {
- /**
- * Creates new form User_Reg
- */
- public User_Reg() {
- initComponents();
- this.getContentPane().setBackground(Color.orange);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setTitle("User-Registration");
- this.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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jInternalFrame1 = new javax.swing.JInternalFrame();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- jLabel6 = new javax.swing.JLabel();
- jLabel7 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jTextField3 = new javax.swing.JTextField();
- jComboBox1 = new javax.swing.JComboBox();
- jComboBox2 = new javax.swing.JComboBox();
- jButton1 = new javax.swing.JButton();
- jPasswordField1 = new javax.swing.JPasswordField();
- jInternalFrame1.setVisible(true);
- javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
- jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
- jInternalFrame1Layout.setHorizontalGroup(
- jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 0, Short.MAX_VALUE)
- );
- jInternalFrame1Layout.setVerticalGroup(
- jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 0, Short.MAX_VALUE)
- );
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(0, 102, 102));
- jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
- jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reg.jpg"))); // NOI18N
- jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel3.setText("Username");
- jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel4.setText("Password");
- jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel5.setText("Email-Id");
- jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel6.setText("Battalion");
- jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
- jLabel7.setText("Region");
- jTextField1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jTextField1ActionPerformed(evt);
- }
- });
- jTextField3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jTextField3ActionPerformed(evt);
- }
- });
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "B1", "B2" }));
- jComboBox1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox1ActionPerformed(evt);
- }
- });
- jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "R1", "R2" }));
- jComboBox2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox2ActionPerformed(evt);
- }
- });
- jButton1.setBackground(new java.awt.Color(0, 0, 102));
- jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
- jButton1.setForeground(new java.awt.Color(0, 255, 255));
- jButton1.setText("Register");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jPasswordField1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(79, 79, 79)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel3)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jLabel4)
- .addGap(6, 6, 6)))
- .addGap(84, 84, 84)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jComboBox2, 0, 154, Short.MAX_VALUE)
- .addComponent(jPasswordField1)
- .addComponent(jTextField1)
- .addComponent(jTextField3)
- .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel5)
- .addComponent(jLabel6))
- .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel2)
- .addGap(27, 27, 27))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(239, 239, 239)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(54, 54, 54)
- .addComponent(jLabel1)))
- .addContainerGap(59, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(21, 21, 21)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(42, 42, 42)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addGap(39, 39, 39)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4))
- .addGap(40, 40, 40)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel5)
- .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(32, 32, 32)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel6)))
- .addGroup(layout.createSequentialGroup()
- .addGap(65, 65, 65)
- .addComponent(jLabel2)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel7))
- .addGap(35, 35, 35)
- .addComponent(jButton1)
- .addGap(79, 79, 79))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jComboBox1ActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- String unm=jTextField1.getText();
- String pwd=jPasswordField1.getText();
- String eid=jTextField3.getText();
- String b=jComboBox1.getSelectedItem().toString();
- String r=jComboBox2.getSelectedItem().toString();
- String ap=b+"^"+r;
- String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
- if(unm.equals("")){
- JOptionPane.showMessageDialog(null,"Please Enter Username");
- }else{
- if(pwd.equals("")){
- JOptionPane.showMessageDialog(null,"Please Enter Password");
- }
- else{
- if(eid.equals("")){
- JOptionPane.showMessageDialog(null,"Please Enter Email ID");
- }
- else{
- if(!eid.matches(EMAIL_REGEX)){
- JOptionPane.showMessageDialog(null,"Please Enter Valid Email ID");
- }
- else{
- try{
- Connection con=database.getConnection();
- PreparedStatement pst=con.prepareStatement("insert into signup values(?,?,?,?,?,?,?)");
- pst.setString(1,unm);
- pst.setString(2,pwd);
- pst.setString(3,eid);
- pst.setString(4,b);
- pst.setString(5,r);
- pst.setString(6,ap);
- pst.setString(7,"Non-Revoked");
- int i=pst.executeUpdate();
- if(i==1){
- JOptionPane.showMessageDialog(null,"Registerd Successfully");
- }
- dispose();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- }}
- }//GEN-LAST:event_jButton1ActionPerformed
- private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jTextField1ActionPerformed
- private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jPasswordField1ActionPerformed
- private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jComboBox2ActionPerformed
- private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_jTextField3ActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new User_Reg().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JComboBox jComboBox2;
- private javax.swing.JInternalFrame jInternalFrame1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JPasswordField jPasswordField1;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JTextField jTextField3;
- // End of variables declaration//GEN-END:variables
- }
- -------------------------------------------------------USER DETAILS-------------------------------------------
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package ABE;
- /**
- *
- * @author ali
- */
- import java.awt.*;
- import java.sql.*;
- import java.util.*;
- import javax.swing.*;
- import javax.swing.table.*;
- public class UserDetails extends JFrame
- {
- public UserDetails (String kauser,String batalion)
- {
- ArrayList columnNames = new ArrayList();
- ArrayList data = new ArrayList();
- // Connect to an MySQL Database, run query, get result set
- String url = "jdbc:mysql://localhost:3306/cp-abe";
- String userid = "root";
- String password = "root";
- String sql = "SELECT * FROM requested where kauser='"+kauser+"' and batalion='"+batalion+"'";
- // Java SE 7 has try-with-resources
- // This will ensure that the sql objects are closed when the program
- // is finished with them
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection connection = DriverManager.getConnection( url, userid, password );
- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery( sql );
- ResultSetMetaData md = rs.getMetaData();
- int columns = md.getColumnCount();
- // Get column names
- for (int i = 1; i <= columns; i++)
- {
- columnNames.add( md.getColumnName(i) );
- }
- // Get row data
- while (rs.next())
- {
- ArrayList row = new ArrayList(columns);
- for (int i = 1; i <= columns; i++)
- {
- row.add( rs.getObject(i) );
- }
- data.add( row );
- }
- }
- catch (Exception e)
- {
- System.out.println( e.getMessage() );
- }
- // Create Vectors and copy over elements from ArrayLists to them
- // Vector is deprecated but I am using them in this example to keep
- // things simple - the best practice would be to create a custom defined
- // class which inherits from the AbstractTableModel class
- Vector columnNamesVector = new Vector();
- Vector dataVector = new Vector();
- for (int i = 0; i < data.size(); i++)
- {
- ArrayList subArray = (ArrayList)data.get(i);
- Vector subVector = new Vector();
- for (int j = 0; j < subArray.size(); j++)
- {
- subVector.add(subArray.get(j));
- }
- dataVector.add(subVector);
- }
- for (int i = 0; i < columnNames.size(); i++ )
- columnNamesVector.add(columnNames.get(i));
- // Create table with database data
- JTable table = new JTable(dataVector, columnNamesVector)
- {
- public Class getColumnClass(int column)
- {
- for (int row = 0; row < getRowCount(); row++)
- {
- Object o = getValueAt(row, column);
- if (o != null)
- {
- return o.getClass();
- }
- }
- return Object.class;
- }
- };
- JScrollPane scrollPane = new JScrollPane( table );
- getContentPane().add( scrollPane );
- JPanel buttonPanel = new JPanel();
- getContentPane().add( buttonPanel, BorderLayout.SOUTH );
- }
- public static void main(String[] args)
- {
- }
- }
- --------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement