Advertisement
Guest User

code snippets

a guest
Mar 31st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 141.82 KB | None | 0 0
  1. -------------------------------------------------------CA-------------------------------------------
  2. /*
  3. * To change this template, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package ABE;
  7.  
  8. import java.awt.Color;
  9. import javax.swing.JFrame;
  10.  
  11. /**
  12. *
  13. * @author ali
  14. */
  15. public class CA extends javax.swing.JFrame {
  16.  
  17. /**
  18. * Creates new form CA
  19. */
  20. public CA() {
  21. initComponents();
  22. this.getContentPane().setBackground(Color.gray);
  23. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  24. this.setTitle("Central_Authority");
  25. this.setResizable(false);
  26. }
  27.  
  28. /**
  29. * This method is called from within the constructor to initialize the form.
  30. * WARNING: Do NOT modify this code. The content of this method is always
  31. * regenerated by the Form Editor.
  32. */
  33. @SuppressWarnings("unchecked")
  34. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  35. private void initComponents() {
  36.  
  37. jLabel1 = new javax.swing.JLabel();
  38. jButton1 = new javax.swing.JButton();
  39. jButton2 = new javax.swing.JButton();
  40. jLabel2 = new javax.swing.JLabel();
  41.  
  42. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  43.  
  44. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  45. jLabel1.setForeground(new java.awt.Color(0, 102, 0));
  46. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  47.  
  48. jButton1.setBackground(new java.awt.Color(255, 0, 0));
  49. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  50. jButton1.setForeground(new java.awt.Color(255, 255, 255));
  51. jButton1.setText("REVOCATION USERS");
  52. jButton1.addActionListener(new java.awt.event.ActionListener() {
  53. public void actionPerformed(java.awt.event.ActionEvent evt) {
  54. jButton1ActionPerformed(evt);
  55. }
  56. });
  57.  
  58. jButton2.setBackground(new java.awt.Color(102, 0, 102));
  59. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  60. jButton2.setText("SECRET CHANNEL");
  61. jButton2.addActionListener(new java.awt.event.ActionListener() {
  62. public void actionPerformed(java.awt.event.ActionEvent evt) {
  63. jButton2ActionPerformed(evt);
  64. }
  65. });
  66.  
  67. jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/per.jpg"))); // NOI18N
  68.  
  69. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  70. getContentPane().setLayout(layout);
  71. layout.setHorizontalGroup(
  72. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  73. .addGroup(layout.createSequentialGroup()
  74. .addGap(31, 31, 31)
  75. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  76. .addComponent(jLabel1)
  77. .addGroup(layout.createSequentialGroup()
  78. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  79. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
  80. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
  81. .addGap(82, 82, 82)
  82. .addComponent(jLabel2)
  83. .addGap(18, 18, 18)))
  84. .addContainerGap(57, Short.MAX_VALUE))
  85. );
  86. layout.setVerticalGroup(
  87. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88. .addGroup(layout.createSequentialGroup()
  89. .addGap(30, 30, 30)
  90. .addComponent(jLabel1)
  91. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  92. .addGroup(layout.createSequentialGroup()
  93. .addGap(67, 67, 67)
  94. .addComponent(jButton1)
  95. .addGap(49, 49, 49)
  96. .addComponent(jButton2))
  97. .addGroup(layout.createSequentialGroup()
  98. .addGap(31, 31, 31)
  99. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
  100. .addContainerGap(74, Short.MAX_VALUE))
  101. );
  102.  
  103. pack();
  104. }// </editor-fold>//GEN-END:initComponents
  105.  
  106. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  107. // TODO add your handling code here
  108. Revocation r=new Revocation();
  109. r.setVisible(true);
  110.  
  111. }//GEN-LAST:event_jButton1ActionPerformed
  112.  
  113. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  114. // TODO add your handling code here:
  115. CAaccept ca=new CAaccept();
  116. ca.setVisible(true);
  117. }//GEN-LAST:event_jButton2ActionPerformed
  118.  
  119. /**
  120. * @param args the command line arguments
  121. */
  122. public static void main(String args[]) {
  123. /* Set the Nimbus look and feel */
  124. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  125. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  126. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  127. */
  128. try {
  129. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  130. if ("Nimbus".equals(info.getName())) {
  131. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  132. break;
  133. }
  134. }
  135. } catch (ClassNotFoundException ex) {
  136. java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  137. } catch (InstantiationException ex) {
  138. java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  139. } catch (IllegalAccessException ex) {
  140. java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  141. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  142. java.util.logging.Logger.getLogger(CA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  143. }
  144. //</editor-fold>
  145.  
  146. /* Create and display the form */
  147. java.awt.EventQueue.invokeLater(new Runnable() {
  148. public void run() {
  149. new CA().setVisible(true);
  150. }
  151. });
  152. }
  153. // Variables declaration - do not modify//GEN-BEGIN:variables
  154. private javax.swing.JButton jButton1;
  155. private javax.swing.JButton jButton2;
  156. private javax.swing.JLabel jLabel1;
  157. private javax.swing.JLabel jLabel2;
  158. // End of variables declaration//GEN-END:variables
  159. }
  160. -------------------------------------------------------CA LOGIN-------------------------------------------
  161. /*
  162. * To change this template, choose Tools | Templates
  163. * and open the template in the editor.
  164. */
  165. package ABE;
  166.  
  167. import java.awt.Color;
  168. import javax.swing.JFrame;
  169. import javax.swing.JOptionPane;
  170.  
  171. /**
  172. *
  173. * @author ali
  174. */
  175. public class CAlogin extends javax.swing.JFrame {
  176.  
  177. /**
  178. * Creates new form CAlogin
  179. */
  180. public CAlogin() {
  181. initComponents();
  182. this.getContentPane().setBackground(Color.PINK);
  183. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  184. this.setTitle("Central_Authority_Login");
  185. this.setResizable(false);
  186. }
  187.  
  188. /**
  189. * This method is called from within the constructor to initialize the form.
  190. * WARNING: Do NOT modify this code. The content of this method is always
  191. * regenerated by the Form Editor.
  192. */
  193. @SuppressWarnings("unchecked")
  194. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  195. private void initComponents() {
  196.  
  197. jLabel1 = new javax.swing.JLabel();
  198. jLabel2 = new javax.swing.JLabel();
  199. jLabel3 = new javax.swing.JLabel();
  200. jTextField1 = new javax.swing.JTextField();
  201. jButton1 = new javax.swing.JButton();
  202. jPasswordField1 = new javax.swing.JPasswordField();
  203. jLabel4 = new javax.swing.JLabel();
  204.  
  205. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  206.  
  207. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  208. jLabel1.setForeground(new java.awt.Color(51, 0, 204));
  209. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  210.  
  211. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  212. jLabel2.setText("Username");
  213.  
  214. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  215. jLabel3.setText("Password");
  216.  
  217. jTextField1.addActionListener(new java.awt.event.ActionListener() {
  218. public void actionPerformed(java.awt.event.ActionEvent evt) {
  219. jTextField1ActionPerformed(evt);
  220. }
  221. });
  222.  
  223. jButton1.setBackground(new java.awt.Color(0, 0, 153));
  224. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  225. jButton1.setForeground(new java.awt.Color(255, 255, 255));
  226. jButton1.setText("Login");
  227. jButton1.addActionListener(new java.awt.event.ActionListener() {
  228. public void actionPerformed(java.awt.event.ActionEvent evt) {
  229. jButton1ActionPerformed(evt);
  230. }
  231. });
  232.  
  233. jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/a.jpg"))); // NOI18N
  234.  
  235. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  236. getContentPane().setLayout(layout);
  237. layout.setHorizontalGroup(
  238. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  239. .addGroup(layout.createSequentialGroup()
  240. .addGap(42, 42, 42)
  241. .addComponent(jLabel1)
  242. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  243. .addGroup(layout.createSequentialGroup()
  244. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  245. .addGroup(layout.createSequentialGroup()
  246. .addGap(232, 232, 232)
  247. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
  248. .addGroup(layout.createSequentialGroup()
  249. .addGap(80, 80, 80)
  250. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  251. .addComponent(jLabel2)
  252. .addComponent(jLabel3))
  253. .addGap(77, 77, 77)
  254. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  255. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
  256. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))))
  257. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  258. .addComponent(jLabel4)
  259. .addGap(20, 20, 20))
  260. );
  261. layout.setVerticalGroup(
  262. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  263. .addGroup(layout.createSequentialGroup()
  264. .addGap(34, 34, 34)
  265. .addComponent(jLabel1)
  266. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  267. .addGroup(layout.createSequentialGroup()
  268. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  269. .addGroup(layout.createSequentialGroup()
  270. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  271. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  272. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  273. .addComponent(jLabel3))
  274. .addGap(41, 41, 41))
  275. .addGroup(layout.createSequentialGroup()
  276. .addGap(66, 66, 66)
  277. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  278. .addComponent(jLabel2)
  279. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  280. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)))
  281. .addComponent(jButton1)
  282. .addGap(49, 49, 49))
  283. .addGroup(layout.createSequentialGroup()
  284. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  285. .addComponent(jLabel4)
  286. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  287. );
  288.  
  289. pack();
  290. }// </editor-fold>//GEN-END:initComponents
  291.  
  292. private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
  293. // TODO add your handling code here:
  294. }//GEN-LAST:event_jTextField1ActionPerformed
  295.  
  296. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  297. // TODO add your handling code here:
  298. if(jTextField1.getText().equals("CA") && jPasswordField1.getText().equals("CA") )
  299. {
  300. CA c=new CA();
  301. c.setVisible(true);
  302. dispose();
  303. }
  304. else{
  305. JOptionPane.showMessageDialog(null,"Incorrect either Username or Password","ERROR",JOptionPane.ERROR_MESSAGE);
  306. }
  307. }//GEN-LAST:event_jButton1ActionPerformed
  308.  
  309. /**
  310. * @param args the command line arguments
  311. */
  312. public static void main(String args[]) {
  313. /* Set the Nimbus look and feel */
  314. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  315. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  316. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  317. */
  318. try {
  319. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  320. if ("Nimbus".equals(info.getName())) {
  321. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  322. break;
  323. }
  324. }
  325. } catch (ClassNotFoundException ex) {
  326. java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  327. } catch (InstantiationException ex) {
  328. java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  329. } catch (IllegalAccessException ex) {
  330. java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  331. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  332. java.util.logging.Logger.getLogger(CAlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  333. }
  334. //</editor-fold>
  335.  
  336. /* Create and display the form */
  337. java.awt.EventQueue.invokeLater(new Runnable() {
  338. public void run() {
  339. new CAlogin().setVisible(true);
  340. }
  341. });
  342. }
  343. // Variables declaration - do not modify//GEN-BEGIN:variables
  344. private javax.swing.JButton jButton1;
  345. private javax.swing.JLabel jLabel1;
  346. private javax.swing.JLabel jLabel2;
  347. private javax.swing.JLabel jLabel3;
  348. private javax.swing.JLabel jLabel4;
  349. private javax.swing.JPasswordField jPasswordField1;
  350. private javax.swing.JTextField jTextField1;
  351. // End of variables declaration//GEN-END:variables
  352. }
  353. -------------------------------------------------------HOME-------------------------------------------
  354. /*
  355. * To change this template, choose Tools | Templates
  356. * and open the template in the editor.
  357. */
  358. package ABE;
  359.  
  360. import java.awt.Color;
  361.  
  362. /**
  363. *
  364. * @author ali
  365. */
  366. public class Home extends javax.swing.JFrame {
  367.  
  368. /**
  369. * Creates new form Home
  370. */
  371. public Home() {
  372. initComponents();
  373. this.getContentPane().setBackground(Color.ORANGE);
  374. }
  375.  
  376. /**
  377. * This method is called from within the constructor to initialize the form.
  378. * WARNING: Do NOT modify this code. The content of this method is always
  379. * regenerated by the Form Editor.
  380. */
  381. @SuppressWarnings("unchecked")
  382. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  383. private void initComponents() {
  384.  
  385. jButton1 = new javax.swing.JButton();
  386. jButton2 = new javax.swing.JButton();
  387. jButton3 = new javax.swing.JButton();
  388. jLabel3 = new javax.swing.JLabel();
  389.  
  390. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  391. setForeground(new java.awt.Color(0, 51, 255));
  392. getContentPane().setLayout(new java.awt.GridBagLayout());
  393.  
  394. jButton1.setText("Sender");
  395. getContentPane().add(jButton1, new java.awt.GridBagConstraints());
  396.  
  397. jButton2.setText("Users");
  398. getContentPane().add(jButton2, new java.awt.GridBagConstraints());
  399.  
  400. jButton3.setText("Key authorities");
  401. getContentPane().add(jButton3, new java.awt.GridBagConstraints());
  402.  
  403. jLabel3.setBackground(new java.awt.Color(51, 51, 0));
  404. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  405. jLabel3.setForeground(new java.awt.Color(0, 102, 0));
  406. jLabel3.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  407. getContentPane().add(jLabel3, new java.awt.GridBagConstraints());
  408.  
  409. pack();
  410. }// </editor-fold>//GEN-END:initComponents
  411.  
  412. /**
  413. * @param args the command line arguments
  414. */
  415. public static void main(String args[]) {
  416. /* Set the Nimbus look and feel */
  417. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  418. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  419. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  420. */
  421. try {
  422. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  423. if ("Nimbus".equals(info.getName())) {
  424. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  425. break;
  426. }
  427. }
  428. } catch (ClassNotFoundException ex) {
  429. java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  430. } catch (InstantiationException ex) {
  431. java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  432. } catch (IllegalAccessException ex) {
  433. java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  434. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  435. java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  436. }
  437. //</editor-fold>
  438.  
  439. /* Create and display the form */
  440. java.awt.EventQueue.invokeLater(new Runnable() {
  441. public void run() {
  442. new Home().setVisible(true);
  443. }
  444. });
  445. }
  446. // Variables declaration - do not modify//GEN-BEGIN:variables
  447. private javax.swing.JButton jButton1;
  448. private javax.swing.JButton jButton2;
  449. private javax.swing.JButton jButton3;
  450. private javax.swing.JLabel jLabel3;
  451. // End of variables declaration//GEN-END:variables
  452. }
  453. -------------------------------------------------------KEY AUTHORITY HOME---------------------------------------------------
  454. /*
  455. * To change this template, choose Tools | Templates
  456. * and open the template in the editor.
  457. */
  458. package ABE;
  459.  
  460. import java.security.Key;
  461. import java.security.Security;
  462.  
  463. import javax.crypto.Cipher;
  464. import javax.crypto.KeyGenerator;
  465. import java.awt.Color;
  466. import java.sql.Connection;
  467. import java.sql.ResultSet;
  468. import java.sql.Statement;
  469. import javax.crypto.KeyGenerator;
  470. import javax.swing.JFrame;
  471. import javax.swing.JOptionPane;
  472.  
  473. /**
  474. *
  475. * @author ali
  476. */
  477. public class KeyAuthorHome extends javax.swing.JFrame {
  478.  
  479. /**
  480. * Creates new form KeyAuthorHome
  481. */
  482. String unm, batalion,unm1,eid,b,r;
  483. ResultSet r1=null;
  484. public KeyAuthorHome(String unm) {
  485. initComponents();
  486. this.getContentPane().setBackground(Color.orange);
  487. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  488. this.setTitle("KeyAuthority-Home");
  489. this.setResizable(false);
  490. this.unm=unm;
  491. }
  492.  
  493. /**r
  494. * This method is called from within the constructor to initialize the form.
  495. * WARNING: Do NOT modify this code. The content of this method is always
  496. * regenerated by the Form Editor.
  497. */
  498. @SuppressWarnings("unchecked")
  499. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  500. private void initComponents() {
  501.  
  502. jInternalFrame1 = new javax.swing.JInternalFrame();
  503. jLabel1 = new javax.swing.JLabel();
  504. jLabel2 = new javax.swing.JLabel();
  505. jTextField1 = new javax.swing.JTextField();
  506. jButton1 = new javax.swing.JButton();
  507. jPanel1 = new javax.swing.JPanel();
  508. jTextField2 = new javax.swing.JTextField();
  509. jTextField5 = new javax.swing.JTextField();
  510. jTextField3 = new javax.swing.JTextField();
  511. jTextField4 = new javax.swing.JTextField();
  512. jButton2 = new javax.swing.JButton();
  513. jLabel3 = new javax.swing.JLabel();
  514. jButton3 = new javax.swing.JButton();
  515. jPasswordField1 = new javax.swing.JPasswordField();
  516. jButton4 = new javax.swing.JButton();
  517.  
  518. jInternalFrame1.setVisible(true);
  519.  
  520. javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
  521. jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
  522. jInternalFrame1Layout.setHorizontalGroup(
  523. jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  524. .addGap(0, 0, Short.MAX_VALUE)
  525. );
  526. jInternalFrame1Layout.setVerticalGroup(
  527. jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  528. .addGap(0, 0, Short.MAX_VALUE)
  529. );
  530.  
  531. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  532.  
  533. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  534. jLabel1.setForeground(new java.awt.Color(204, 0, 153));
  535. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  536.  
  537. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  538. jLabel2.setForeground(new java.awt.Color(51, 51, 0));
  539. jLabel2.setText("Enter Username");
  540.  
  541. jButton1.setBackground(new java.awt.Color(153, 153, 0));
  542. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  543. jButton1.setForeground(new java.awt.Color(51, 0, 0));
  544. jButton1.setText("Request Details");
  545. jButton1.addActionListener(new java.awt.event.ActionListener() {
  546. public void actionPerformed(java.awt.event.ActionEvent evt) {
  547. jButton1ActionPerformed(evt);
  548. }
  549. });
  550.  
  551. 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
  552.  
  553. jTextField2.setEditable(false);
  554. jTextField2.setBorder(null);
  555.  
  556. jTextField5.setEditable(false);
  557. jTextField5.setBorder(null);
  558.  
  559. jTextField3.setEditable(false);
  560. jTextField3.setBorder(null);
  561. jTextField3.addActionListener(new java.awt.event.ActionListener() {
  562. public void actionPerformed(java.awt.event.ActionEvent evt) {
  563. jTextField3ActionPerformed(evt);
  564. }
  565. });
  566.  
  567. jTextField4.setEditable(false);
  568. jTextField4.setBorder(null);
  569.  
  570. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  571. jPanel1.setLayout(jPanel1Layout);
  572. jPanel1Layout.setHorizontalGroup(
  573. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  574. .addGroup(jPanel1Layout.createSequentialGroup()
  575. .addContainerGap()
  576. .addComponent(jTextField2)
  577. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  578. .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
  579. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  580. .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
  581. .addGap(18, 18, 18)
  582. .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
  583. .addContainerGap())
  584. );
  585. jPanel1Layout.setVerticalGroup(
  586. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  587. .addGroup(jPanel1Layout.createSequentialGroup()
  588. .addGap(20, 20, 20)
  589. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  590. .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
  591. .addComponent(jTextField2)
  592. .addComponent(jTextField4)
  593. .addComponent(jTextField5))
  594. .addContainerGap())
  595. );
  596.  
  597. jButton2.setBackground(new java.awt.Color(255, 51, 153));
  598. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  599. jButton2.setForeground(new java.awt.Color(0, 0, 255));
  600. jButton2.setText("GetParameters");
  601. jButton2.addActionListener(new java.awt.event.ActionListener() {
  602. public void actionPerformed(java.awt.event.ActionEvent evt) {
  603. jButton2ActionPerformed(evt);
  604. }
  605. });
  606.  
  607. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  608. jLabel3.setForeground(new java.awt.Color(153, 0, 0));
  609. jLabel3.setText("Secret Key");
  610.  
  611. jButton3.setBackground(new java.awt.Color(0, 204, 204));
  612. jButton3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  613. jButton3.setForeground(new java.awt.Color(51, 0, 51));
  614. jButton3.setText("GenerateKey");
  615. jButton3.addActionListener(new java.awt.event.ActionListener() {
  616. public void actionPerformed(java.awt.event.ActionEvent evt) {
  617. jButton3ActionPerformed(evt);
  618. }
  619. });
  620.  
  621. jPasswordField1.setEditable(false);
  622.  
  623. jButton4.setBackground(new java.awt.Color(51, 153, 0));
  624. jButton4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  625. jButton4.setForeground(new java.awt.Color(255, 255, 255));
  626. jButton4.setText("SEND");
  627. jButton4.addActionListener(new java.awt.event.ActionListener() {
  628. public void actionPerformed(java.awt.event.ActionEvent evt) {
  629. jButton4ActionPerformed(evt);
  630. }
  631. });
  632.  
  633. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  634. getContentPane().setLayout(layout);
  635. layout.setHorizontalGroup(
  636. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  637. .addGroup(layout.createSequentialGroup()
  638. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  639. .addGroup(layout.createSequentialGroup()
  640. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  641. .addGroup(layout.createSequentialGroup()
  642. .addGap(46, 46, 46)
  643. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  644. .addComponent(jLabel1)
  645. .addGroup(layout.createSequentialGroup()
  646. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
  647. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  648. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  649. .addComponent(jButton2)
  650. .addGroup(layout.createSequentialGroup()
  651. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
  652. .addGap(34, 34, 34)
  653. .addComponent(jButton1))))))
  654. .addGroup(layout.createSequentialGroup()
  655. .addGap(47, 47, 47)
  656. .addComponent(jLabel3)
  657. .addGap(19, 19, 19)
  658. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
  659. .addGap(18, 18, 18)
  660. .addComponent(jButton3))
  661. .addGroup(layout.createSequentialGroup()
  662. .addGap(146, 146, 146)
  663. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
  664. .addGap(0, 68, Short.MAX_VALUE))
  665. .addGroup(layout.createSequentialGroup()
  666. .addContainerGap()
  667. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  668. .addContainerGap())
  669. );
  670. layout.setVerticalGroup(
  671. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  672. .addGroup(layout.createSequentialGroup()
  673. .addGap(23, 23, 23)
  674. .addComponent(jLabel1)
  675. .addGap(56, 56, 56)
  676. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  677. .addComponent(jLabel2)
  678. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  679. .addComponent(jButton1))
  680. .addGap(28, 28, 28)
  681. .addComponent(jButton2)
  682. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  683. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  684. .addGap(34, 34, 34)
  685. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  686. .addComponent(jLabel3)
  687. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  688. .addComponent(jButton3))
  689. .addGap(18, 18, 18)
  690. .addComponent(jButton4)
  691. .addContainerGap(53, Short.MAX_VALUE))
  692. );
  693.  
  694. pack();
  695. }// </editor-fold>//GEN-END:initComponents
  696.  
  697. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  698. // TODO add your handling code here:
  699.  
  700.  
  701. try{
  702. Connection con=database.getConnection();
  703. Statement st=con.createStatement();
  704. Statement st1=con.createStatement();
  705. ResultSet r=st.executeQuery("select batalion from keysignup where unm='"+unm+"'");
  706. if(r.next()){
  707. batalion=r.getString(1);
  708.  
  709. }
  710.  
  711. }catch(Exception e){
  712. e.printStackTrace();
  713. }
  714. UserDetails frame=new UserDetails(unm,batalion);
  715.  
  716. frame.pack();
  717. frame.setVisible(true);
  718.  
  719. }//GEN-LAST:event_jButton1ActionPerformed
  720.  
  721. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  722. // TODO add your handling code here:
  723.  
  724. String unm=jTextField1.getText();
  725. try{
  726. Connection con=database.getConnection();
  727. Statement st=con.createStatement();
  728. Statement st1=con.createStatement();
  729. r1=st.executeQuery("select *from signup where unm='"+unm+"'");
  730. if(r1.next())
  731. {
  732. unm1=r1.getString(1);
  733. jTextField2.setText(r1.getString(1));
  734. eid=r1.getString(3);
  735. jTextField3.setText(r1.getString(3));
  736. b=r1.getString(4);
  737. jTextField4.setText(r1.getString(4));
  738. r=r1.getString(5);
  739. jTextField5.setText(r1.getString(5));
  740.  
  741. }
  742. }catch(Exception e){ e.printStackTrace();}
  743.  
  744.  
  745. }//GEN-LAST:event_jButton2ActionPerformed
  746.  
  747. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  748. // TODO add your handling code here:
  749. try{
  750. KeyGenerator KeyGen = KeyGenerator.getInstance("AES");
  751. KeyGen.init(256);
  752.  
  753. Key wrapKey = KeyGen.generateKey();
  754. System.out.println("key="+((wrapKey.toString()).getBytes()).toString());
  755.  
  756. jPasswordField1.setText(((wrapKey.toString()).getBytes()).toString());
  757. }catch(Exception e){
  758. e.printStackTrace();
  759. }
  760.  
  761.  
  762. }//GEN-LAST:event_jButton3ActionPerformed
  763.  
  764. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  765. // TODO add your handling code here:
  766.  
  767. SendKey sk=new SendKey();
  768. sk.setKey(jPasswordField1.getText());
  769. try{
  770. Connection con1=database.getConnection();
  771.  
  772. Statement st2=con1.createStatement();
  773. Statement st3=con1.createStatement();
  774. int i=st3.executeUpdate("delete from key_");
  775. System.out.println(i);
  776. int r2=st2.executeUpdate("insert into key_ values('"+jPasswordField1.getText()+"')");
  777. if(r2==1)
  778. JOptionPane.showMessageDialog(null,"Secret-Key Sent to Sender Successfully");
  779. dispose();
  780. }catch(Exception e){
  781. e.printStackTrace();
  782. }
  783.  
  784. // System.out.println("sk="+sk.getKey());
  785.  
  786. }//GEN-LAST:event_jButton4ActionPerformed
  787.  
  788. private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
  789. // TODO add your handling code here:
  790. }//GEN-LAST:event_jTextField3ActionPerformed
  791.  
  792. /**
  793. * @param args the command line arguments
  794. */
  795. public static void main(String args[]) {
  796. /* Set the Nimbus look and feel */
  797. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  798. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  799. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  800. */
  801. try {
  802. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  803. if ("Nimbus".equals(info.getName())) {
  804. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  805. break;
  806. }
  807. }
  808. } catch (ClassNotFoundException ex) {
  809. java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  810. } catch (InstantiationException ex) {
  811. java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  812. } catch (IllegalAccessException ex) {
  813. java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  814. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  815. java.util.logging.Logger.getLogger(KeyAuthorHome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  816. }
  817. //</editor-fold>//
  818.  
  819. /* Create and display the form */
  820. java.awt.EventQueue.invokeLater(new Runnable() {
  821. public void run() {
  822. new KeyAuthorHome("a").setVisible(true);
  823. }
  824. });
  825. }
  826. // Variables declaration - do not modify//GEN-BEGIN:variables
  827. private javax.swing.JButton jButton1;
  828. private javax.swing.JButton jButton2;
  829. private javax.swing.JButton jButton3;
  830. private javax.swing.JButton jButton4;
  831. private javax.swing.JInternalFrame jInternalFrame1;
  832. private javax.swing.JLabel jLabel1;
  833. private javax.swing.JLabel jLabel2;
  834. private javax.swing.JLabel jLabel3;
  835. private javax.swing.JPanel jPanel1;
  836. private javax.swing.JPasswordField jPasswordField1;
  837. private javax.swing.JTextField jTextField1;
  838. private javax.swing.JTextField jTextField2;
  839. private javax.swing.JTextField jTextField3;
  840. private javax.swing.JTextField jTextField4;
  841. private javax.swing.JTextField jTextField5;
  842. // End of variables declaration//GEN-END:variables
  843. }
  844. ---------------------------------------------------------KEY AUTHORITY LOGIN----------------------------------
  845. /*
  846. * To change this template, choose Tools | Templates
  847. * and open the template in the editor.
  848. */
  849. package ABE;
  850.  
  851. import java.awt.Color;
  852. import java.net.CacheResponse;
  853. import java.sql.Connection;
  854. import java.sql.ResultSet;
  855. import java.sql.Statement;
  856. import javax.swing.JFrame;
  857. import javax.swing.JOptionPane;
  858.  
  859. /**
  860. *
  861. * @author ali
  862. */
  863. public class KeyAuthorLogin extends javax.swing.JFrame {
  864.  
  865. /**
  866. * Creates new form KeyAuthorLogin
  867. */
  868. public KeyAuthorLogin() {
  869. initComponents();
  870. this.getContentPane().setBackground(Color.MAGENTA);
  871. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  872. this.setTitle("KeyAuhority-Login");
  873. this.setResizable(false);
  874. }
  875.  
  876. /**
  877. * This method is called from within the construc
  878. * tor to initialize the form.
  879. * WARNING: Do NOT modify this code. The content of this method is always
  880. * regenerated by the Form Editor.
  881. */
  882. @SuppressWarnings("unchecked")
  883. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  884. private void initComponents() {
  885.  
  886. jLabel1 = new javax.swing.JLabel();
  887. jLabel2 = new javax.swing.JLabel();
  888. jLabel3 = new javax.swing.JLabel();
  889. jTextField1 = new javax.swing.JTextField();
  890. jButton1 = new javax.swing.JButton();
  891. jButton2 = new javax.swing.JButton();
  892. jPasswordField1 = new javax.swing.JPasswordField();
  893. jLabel4 = new javax.swing.JLabel();
  894.  
  895. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  896.  
  897. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  898. jLabel1.setForeground(new java.awt.Color(51, 51, 0));
  899. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  900.  
  901. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  902. jLabel2.setForeground(new java.awt.Color(0, 51, 51));
  903. jLabel2.setText("Username");
  904.  
  905. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  906. jLabel3.setForeground(new java.awt.Color(51, 51, 51));
  907. jLabel3.setText("Password");
  908.  
  909. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  910. jButton1.setForeground(new java.awt.Color(204, 102, 0));
  911. jButton1.setText("Login");
  912. jButton1.addActionListener(new java.awt.event.ActionListener() {
  913. public void actionPerformed(java.awt.event.ActionEvent evt) {
  914. jButton1ActionPerformed(evt);
  915. }
  916. });
  917.  
  918. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  919. jButton2.setForeground(new java.awt.Color(0, 102, 102));
  920. jButton2.setText("NewUser");
  921. jButton2.addActionListener(new java.awt.event.ActionListener() {
  922. public void actionPerformed(java.awt.event.ActionEvent evt) {
  923. jButton2ActionPerformed(evt);
  924. }
  925. });
  926.  
  927. jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
  928. public void actionPerformed(java.awt.event.ActionEvent evt) {
  929. jPasswordField1ActionPerformed(evt);
  930. }
  931. });
  932.  
  933. jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/l1.jpg"))); // NOI18N
  934. jLabel4.setText("jLabel4");
  935.  
  936. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  937. getContentPane().setLayout(layout);
  938. layout.setHorizontalGroup(
  939. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  940. .addGroup(layout.createSequentialGroup()
  941. .addContainerGap()
  942. .addComponent(jLabel1)
  943. .addContainerGap())
  944. .addGroup(layout.createSequentialGroup()
  945. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  946. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  947. .addGroup(layout.createSequentialGroup()
  948. .addGap(45, 45, 45)
  949. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
  950. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  951. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
  952. .addGroup(layout.createSequentialGroup()
  953. .addGap(148, 148, 148)
  954. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
  955. .addGroup(layout.createSequentialGroup()
  956. .addContainerGap()
  957. .addComponent(jLabel3)
  958. .addGap(18, 18, 18)
  959. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
  960. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  961. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  962. .addGroup(layout.createSequentialGroup()
  963. .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
  964. .addGap(63, 63, 63))
  965. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  966. .addComponent(jButton2)
  967. .addGap(119, 119, 119))))
  968. );
  969. layout.setVerticalGroup(
  970. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  971. .addGroup(layout.createSequentialGroup()
  972. .addGap(41, 41, 41)
  973. .addComponent(jLabel1)
  974. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  975. .addGroup(layout.createSequentialGroup()
  976. .addGap(66, 66, 66)
  977. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  978. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  979. .addComponent(jLabel2))
  980. .addGap(61, 61, 61)
  981. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  982. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  983. .addComponent(jLabel3))
  984. .addGap(40, 40, 40))
  985. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  986. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  987. .addComponent(jLabel4)
  988. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
  989. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  990. .addComponent(jButton2)
  991. .addComponent(jButton1))
  992. .addContainerGap(87, Short.MAX_VALUE))
  993. );
  994.  
  995. pack();
  996. }// </editor-fold>//GEN-END:initComponents
  997.  
  998. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  999. // TODO add your handling code here:
  1000. String unm=jTextField1.getText();
  1001. String pwd=jPasswordField1.getText();
  1002. try{
  1003. Connection con=database.getConnection();
  1004. Statement st=con.createStatement();
  1005. Statement st1=con.createStatement();
  1006. ResultSet r=st.executeQuery("select *from keysignup where unm='"+unm+"' and pwd='"+pwd+"'");
  1007. if(r.next())
  1008. {
  1009. ResultSet r1=st.executeQuery("select *from keysignup where unm='"+unm+"' and status='Not-Accepted'");
  1010. if(r1.next())
  1011. {
  1012. JOptionPane.showMessageDialog(null,"Your Request is Under the Process...");
  1013. }
  1014. else{
  1015. KeyAuthorHome kah=new KeyAuthorHome(unm);
  1016. kah.setVisible(true);
  1017. dispose();
  1018. }
  1019. }else{
  1020. JOptionPane.showMessageDialog(null,"Incorrect Either Username or Password", "Error",JOptionPane.ERROR_MESSAGE);
  1021.  
  1022. }
  1023. }catch(Exception e){
  1024. e.printStackTrace();
  1025. }
  1026. }//GEN-LAST:event_jButton1ActionPerformed
  1027.  
  1028. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  1029. // TODO add your handling code here
  1030. KeyAuthorReg kreg=new KeyAuthorReg();
  1031. kreg.setVisible(true);
  1032. }//GEN-LAST:event_jButton2ActionPerformed
  1033.  
  1034. private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
  1035. // TODO add your handling code here:
  1036. }//GEN-LAST:event_jPasswordField1ActionPerformed
  1037.  
  1038. /**
  1039. * @param args the command line arguments
  1040. */
  1041. public static void main(String args[]) {
  1042. /* Set the Nimbus look and feel */
  1043. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  1044. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  1045. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  1046. */
  1047. try {
  1048. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  1049. if ("Nimbus".equals(info.getName())) {
  1050. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  1051. break;
  1052. }
  1053. }
  1054. } catch (ClassNotFoundException ex) {
  1055. java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1056. } catch (InstantiationException ex) {
  1057. java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1058. } catch (IllegalAccessException ex) {
  1059. java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1060. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  1061. java.util.logging.Logger.getLogger(KeyAuthorLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1062. }
  1063. //</editor-fold>
  1064.  
  1065. /* Create and display the form */
  1066. java.awt.EventQueue.invokeLater(new Runnable() {
  1067. public void run() {
  1068. new KeyAuthorLogin().setVisible(true);
  1069. }
  1070. });
  1071. }
  1072. // Variables declaration - do not modify//GEN-BEGIN:variables
  1073. private javax.swing.JButton jButton1;
  1074. private javax.swing.JButton jButton2;
  1075. private javax.swing.JLabel jLabel1;
  1076. private javax.swing.JLabel jLabel2;
  1077. private javax.swing.JLabel jLabel3;
  1078. private javax.swing.JLabel jLabel4;
  1079. private javax.swing.JPasswordField jPasswordField1;
  1080. private javax.swing.JTextField jTextField1;
  1081. // End of variables declaration//GEN-END:variables
  1082. }
  1083. -------------------------------------------------------KEY AUTHORITY REGISTRATION-------------------------------------
  1084. /*
  1085. * To change this template, choose Tools | Templates
  1086. * and open the template in the editor.
  1087. */
  1088. package ABE;
  1089.  
  1090. import java.awt.Color;
  1091. import java.sql.Connection;
  1092. import java.sql.PreparedStatement;
  1093. import javax.swing.JFrame;
  1094. import javax.swing.JOptionPane;
  1095.  
  1096. /**
  1097. *
  1098. * @author ali
  1099. */
  1100. public class KeyAuthorReg extends javax.swing.JFrame {
  1101.  
  1102. /**
  1103. * Creates new form KeyAuthorReg
  1104. */
  1105. public KeyAuthorReg() {
  1106. initComponents();
  1107. this.getContentPane().setBackground(Color.yellow);
  1108. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  1109. this.setTitle("KeyAuthority-Registration");
  1110. this.setResizable(false);
  1111. }
  1112.  
  1113. /**
  1114. * This method is called from within the constructor to initialize the form.
  1115. * WARNING: Do NOT modify this code. The content of this method is always
  1116. * regenerated by the Form Editor.
  1117. */
  1118. @SuppressWarnings("unchecked")
  1119. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  1120. private void initComponents() {
  1121.  
  1122. jLabel1 = new javax.swing.JLabel();
  1123. jLabel2 = new javax.swing.JLabel();
  1124. jLabel3 = new javax.swing.JLabel();
  1125. jLabel4 = new javax.swing.JLabel();
  1126. jTextField1 = new javax.swing.JTextField();
  1127. jTextField2 = new javax.swing.JTextField();
  1128. jLabel5 = new javax.swing.JLabel();
  1129. jButton1 = new javax.swing.JButton();
  1130. jComboBox1 = new javax.swing.JComboBox();
  1131. jLabel6 = new javax.swing.JLabel();
  1132. jLabel7 = new javax.swing.JLabel();
  1133. jPasswordField1 = new javax.swing.JPasswordField();
  1134.  
  1135. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  1136.  
  1137. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1138. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  1139.  
  1140. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  1141. jLabel2.setText("Username");
  1142.  
  1143. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  1144. jLabel3.setText("Email-Id");
  1145.  
  1146. jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  1147. jLabel4.setText("Battalion");
  1148.  
  1149. jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  1150. jLabel5.setText("Password");
  1151.  
  1152. jButton1.setBackground(new java.awt.Color(0, 153, 102));
  1153. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  1154. jButton1.setForeground(new java.awt.Color(0, 102, 102));
  1155. jButton1.setText("Submit");
  1156. jButton1.addActionListener(new java.awt.event.ActionListener() {
  1157. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1158. jButton1ActionPerformed(evt);
  1159. }
  1160. });
  1161.  
  1162. jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "B1", "B2" }));
  1163. jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  1164. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1165. jComboBox1ActionPerformed(evt);
  1166. }
  1167. });
  1168.  
  1169. jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/key.jpg"))); // NOI18N
  1170.  
  1171. jLabel7.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
  1172. jLabel7.setForeground(new java.awt.Color(102, 0, 102));
  1173. jLabel7.setText("Key-Authority Registration");
  1174.  
  1175. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1176. getContentPane().setLayout(layout);
  1177. layout.setHorizontalGroup(
  1178. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1179. .addGroup(layout.createSequentialGroup()
  1180. .addGap(79, 79, 79)
  1181. .addComponent(jLabel1)
  1182. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1183. .addGroup(layout.createSequentialGroup()
  1184. .addGap(55, 55, 55)
  1185. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1186. .addComponent(jLabel7)
  1187. .addGroup(layout.createSequentialGroup()
  1188. .addGap(45, 45, 45)
  1189. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1190. .addComponent(jLabel5)
  1191. .addComponent(jLabel2)
  1192. .addComponent(jLabel3)
  1193. .addComponent(jLabel4))))
  1194. .addGap(30, 30, 30)
  1195. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1196. .addComponent(jTextField1)
  1197. .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.TRAILING)
  1198. .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  1199. .addGroup(layout.createSequentialGroup()
  1200. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  1201. .addGap(0, 4, Short.MAX_VALUE))
  1202. .addComponent(jPasswordField1))
  1203. .addGap(51, 51, 51)
  1204. .addComponent(jLabel6)
  1205. .addGap(25, 25, 25))
  1206. );
  1207. layout.setVerticalGroup(
  1208. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1209. .addGroup(layout.createSequentialGroup()
  1210. .addGap(30, 30, 30)
  1211. .addComponent(jLabel1)
  1212. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
  1213. .addComponent(jLabel7)
  1214. .addGap(32, 32, 32)
  1215. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1216. .addComponent(jLabel6)
  1217. .addGroup(layout.createSequentialGroup()
  1218. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1219. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1220. .addComponent(jLabel2))
  1221. .addGap(31, 31, 31)
  1222. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1223. .addComponent(jLabel5)
  1224. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1225. .addGap(32, 32, 32)
  1226. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1227. .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1228. .addComponent(jLabel3))
  1229. .addGap(28, 28, 28)
  1230. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1231. .addComponent(jLabel4)
  1232. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1233. .addGap(31, 31, 31)
  1234. .addComponent(jButton1)))
  1235. .addGap(88, 88, 88))
  1236. );
  1237.  
  1238. pack();
  1239. }// </editor-fold>//GEN-END:initComponents
  1240.  
  1241. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  1242. // TODO add your handling code here:
  1243. String unm=jTextField1.getText();
  1244. String pwd=jPasswordField1.getText();
  1245. String eid=jTextField2.getText();
  1246. String b= jComboBox1.getSelectedItem().toString();
  1247.  
  1248. try{
  1249. Connection con=database.getConnection();
  1250. PreparedStatement pst=con.prepareStatement("insert into keysignup values(?,?,?,?,?)");
  1251. pst.setString(1,unm);
  1252. pst.setString(2,pwd);
  1253. pst.setString(3,eid);
  1254. pst.setString(4,b);
  1255. pst.setString(5,"Not-Accepted");
  1256.  
  1257. int i=pst.executeUpdate();
  1258. if(i==1){
  1259. JOptionPane.showMessageDialog(null,"Key-Authority Registerd Successfully");
  1260. }
  1261. dispose();
  1262. }catch(Exception e){
  1263. e.printStackTrace();
  1264.  
  1265. }
  1266.  
  1267. }//GEN-LAST:event_jButton1ActionPerformed
  1268.  
  1269. private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
  1270. // TODO add your handling code here:
  1271. }//GEN-LAST:event_jComboBox1ActionPerformed
  1272.  
  1273. /**
  1274. * @param args the command line arguments
  1275. */
  1276. public static void main(String args[]) {
  1277. /* Set the Nimbus look and feel */
  1278. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  1279. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  1280. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  1281. */
  1282. try {
  1283. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  1284. if ("Nimbus".equals(info.getName())) {
  1285. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  1286. break;
  1287. }
  1288. }
  1289. } catch (ClassNotFoundException ex) {
  1290. java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1291. } catch (InstantiationException ex) {
  1292. java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1293. } catch (IllegalAccessException ex) {
  1294. java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1295. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  1296. java.util.logging.Logger.getLogger(KeyAuthorReg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1297. }
  1298. //</editor-fold>
  1299.  
  1300. /* Create and display the form */
  1301. java.awt.EventQueue.invokeLater(new Runnable() {
  1302. public void run() {
  1303. new KeyAuthorReg().setVisible(true);
  1304. }
  1305. });
  1306. }
  1307. // Variables declaration - do not modify//GEN-BEGIN:variables
  1308. private javax.swing.JButton jButton1;
  1309. private javax.swing.JComboBox jComboBox1;
  1310. private javax.swing.JLabel jLabel1;
  1311. private javax.swing.JLabel jLabel2;
  1312. private javax.swing.JLabel jLabel3;
  1313. private javax.swing.JLabel jLabel4;
  1314. private javax.swing.JLabel jLabel5;
  1315. private javax.swing.JLabel jLabel6;
  1316. private javax.swing.JLabel jLabel7;
  1317. private javax.swing.JPasswordField jPasswordField1;
  1318. private javax.swing.JTextField jTextField1;
  1319. private javax.swing.JTextField jTextField2;
  1320. // End of variables declaration//GEN-END:variables
  1321. }
  1322. -------------------------------------------------------MAIN-----------------------------------------------------
  1323. /*
  1324. * To change this template, choose Tools | Templates
  1325. * and open the template in the editor.
  1326. */
  1327. package ABE;
  1328.  
  1329. import java.awt.Color;
  1330. import javax.swing.JFrame;
  1331.  
  1332. /**
  1333. *
  1334. * @author ali
  1335. */
  1336. public class Main extends javax.swing.JFrame {
  1337.  
  1338. /**
  1339. * Creates new form Main
  1340. */
  1341. public Main() {
  1342. initComponents();
  1343. this.setTitle("CP-ABE FOR SECURE DATA");
  1344.  
  1345. this.setResizable(false);
  1346. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  1347. this.getContentPane().setBackground(Color.orange);
  1348. }
  1349.  
  1350. /**
  1351. * This method is called from within the constructor to initialize the form.
  1352. * WARNING: Do NOT modify this code. The content of this method is always
  1353. * regenerated by the Form Editor.
  1354. */
  1355. @SuppressWarnings("unchecked")
  1356. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  1357. private void initComponents() {
  1358.  
  1359. jLabel2 = new javax.swing.JLabel();
  1360. jButton1 = new javax.swing.JButton();
  1361. jButton2 = new javax.swing.JButton();
  1362. jButton3 = new javax.swing.JButton();
  1363. jPanel1 = new javax.swing.JPanel();
  1364. jLabel1 = new javax.swing.JLabel();
  1365.  
  1366. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  1367.  
  1368. jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/arc.png"))); // NOI18N
  1369.  
  1370. jButton1.setBackground(new java.awt.Color(0, 153, 0));
  1371. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1372. jButton1.setForeground(new java.awt.Color(255, 153, 255));
  1373. jButton1.setText("Sender");
  1374. jButton1.addActionListener(new java.awt.event.ActionListener() {
  1375. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1376. jButton1ActionPerformed(evt);
  1377. }
  1378. });
  1379.  
  1380. jButton2.setBackground(new java.awt.Color(0, 102, 102));
  1381. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1382. jButton2.setForeground(new java.awt.Color(51, 51, 0));
  1383. jButton2.setText("Users");
  1384. jButton2.addActionListener(new java.awt.event.ActionListener() {
  1385. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1386. jButton2ActionPerformed(evt);
  1387. }
  1388. });
  1389.  
  1390. jButton3.setBackground(new java.awt.Color(255, 51, 255));
  1391. jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1392. jButton3.setForeground(new java.awt.Color(0, 51, 204));
  1393. jButton3.setText("Key Authority");
  1394. jButton3.addActionListener(new java.awt.event.ActionListener() {
  1395. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1396. jButton3ActionPerformed(evt);
  1397. }
  1398. });
  1399.  
  1400. jLabel1.setBackground(new java.awt.Color(0, 0, 204));
  1401. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  1402. jLabel1.setForeground(new java.awt.Color(51, 51, 0));
  1403. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  1404.  
  1405. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  1406. jPanel1.setLayout(jPanel1Layout);
  1407. jPanel1Layout.setHorizontalGroup(
  1408. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1409. .addGroup(jPanel1Layout.createSequentialGroup()
  1410. .addContainerGap()
  1411. .addComponent(jLabel1)
  1412. .addContainerGap())
  1413. );
  1414. jPanel1Layout.setVerticalGroup(
  1415. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1416. .addGroup(jPanel1Layout.createSequentialGroup()
  1417. .addContainerGap()
  1418. .addComponent(jLabel1)
  1419. .addContainerGap())
  1420. );
  1421.  
  1422. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1423. getContentPane().setLayout(layout);
  1424. layout.setHorizontalGroup(
  1425. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1426. .addGroup(layout.createSequentialGroup()
  1427. .addGap(45, 45, 45)
  1428. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1429. .addGroup(layout.createSequentialGroup()
  1430. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1431. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1432. .addGroup(layout.createSequentialGroup()
  1433. .addGap(7, 7, 7)
  1434. .addComponent(jLabel2)
  1435. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
  1436. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1437. .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
  1438. .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
  1439. .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
  1440. .addGap(25, 25, 25))))
  1441. );
  1442. layout.setVerticalGroup(
  1443. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1444. .addGroup(layout.createSequentialGroup()
  1445. .addGap(36, 36, 36)
  1446. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1447. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1448. .addGroup(layout.createSequentialGroup()
  1449. .addGap(113, 113, 113)
  1450. .addComponent(jButton1)
  1451. .addGap(64, 64, 64)
  1452. .addComponent(jButton2)
  1453. .addGap(63, 63, 63)
  1454. .addComponent(jButton3))
  1455. .addGroup(layout.createSequentialGroup()
  1456. .addGap(18, 18, 18)
  1457. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE)))
  1458. .addContainerGap(46, Short.MAX_VALUE))
  1459. );
  1460.  
  1461. pack();
  1462. }// </editor-fold>//GEN-END:initComponents
  1463.  
  1464. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  1465. // TODO add your handling code here:
  1466. Sender s=new Sender();
  1467. s.setVisible(true);
  1468.  
  1469. }//GEN-LAST:event_jButton1ActionPerformed
  1470.  
  1471. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  1472. // TODO add your handling code here:
  1473. KeyAuthorLogin kl=new KeyAuthorLogin();
  1474. kl.setVisible(true);
  1475. }//GEN-LAST:event_jButton3ActionPerformed
  1476.  
  1477. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  1478. // TODO add your handling code here:
  1479. User_Login ul=new User_Login();
  1480. ul.setVisible(true);
  1481. }//GEN-LAST:event_jButton2ActionPerformed
  1482.  
  1483. /**
  1484. * @param args the command line arguments
  1485. */
  1486. public static void main(String args[]) {
  1487. /* Set the Nimbus look and feel */
  1488. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  1489. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  1490. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  1491. */
  1492. try {
  1493. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  1494. if ("Nimbus".equals(info.getName())) {
  1495. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  1496. break;
  1497. }
  1498. }
  1499. } catch (ClassNotFoundException ex) {
  1500. java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1501. } catch (InstantiationException ex) {
  1502. java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1503. } catch (IllegalAccessException ex) {
  1504. java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1505. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  1506. java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1507. }
  1508. //</editor-fold>
  1509.  
  1510. /* Create and display the form */
  1511. java.awt.EventQueue.invokeLater(new Runnable() {
  1512. public void run() {
  1513. new Main().setVisible(true);
  1514. }
  1515. });
  1516. }
  1517. // Variables declaration - do not modify//GEN-BEGIN:variables
  1518. private javax.swing.JButton jButton1;
  1519. private javax.swing.JButton jButton2;
  1520. private javax.swing.JButton jButton3;
  1521. private javax.swing.JLabel jLabel1;
  1522. private javax.swing.JLabel jLabel2;
  1523. private javax.swing.JPanel jPanel1;
  1524. // End of variables declaration//GEN-END:variables
  1525. }
  1526. ------------------------------------------------------SENDER---------------------------------------------------
  1527. /*
  1528. * To change this template, choose Tools | Templates
  1529. * and open the template in the editor.
  1530. */
  1531. package ABE;
  1532.  
  1533. import java.awt.Color;
  1534. import java.awt.FileDialog;
  1535. import java.io.File;
  1536. import java.io.FileInputStream;
  1537. import java.io.InputStream;
  1538. import java.sql.Connection;
  1539. import java.sql.PreparedStatement;
  1540. import java.sql.ResultSet;
  1541. import javax.swing.JFrame;
  1542. import javax.swing.JLabel;
  1543. import javax.swing.border.Border;
  1544. import javax.swing.border.LineBorder;
  1545. import javax.swing.border.TitledBorder;
  1546.  
  1547. /**
  1548. *
  1549. * @author ali
  1550. */
  1551. public class Sender extends javax.swing.JFrame {
  1552.  
  1553. /**
  1554. * Creates new form DataUploading
  1555. */
  1556. String filesel,f4;
  1557. public Sender() {
  1558. initComponents();
  1559. this.getContentPane().setBackground(Color.green);
  1560. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  1561. Border thickBorder = new LineBorder(Color.WHITE, 2);
  1562.  
  1563. JLabel titb=new JLabel();
  1564. TitledBorder titled = new TitledBorder("sensor1 Monitor");
  1565. titb.setBorder(thickBorder);
  1566. this.setTitle("Sender");
  1567. this.setResizable(false);
  1568.  
  1569. }
  1570.  
  1571. /**
  1572. * This method is called from within the constructor to initialize the form.
  1573. * WARNING: Do NOT modify this code. The content of this method is always
  1574. * regenerated by the Form Editor.
  1575. */
  1576. @SuppressWarnings("unchecked")
  1577. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  1578. private void initComponents() {
  1579.  
  1580. jLabel1 = new javax.swing.JLabel();
  1581. jLabel2 = new javax.swing.JLabel();
  1582. jTextField2 = new javax.swing.JTextField();
  1583. jButton2 = new javax.swing.JButton();
  1584. jButton1 = new javax.swing.JButton();
  1585. jButton3 = new javax.swing.JButton();
  1586. jPanel1 = new javax.swing.JPanel();
  1587. jScrollPane1 = new javax.swing.JScrollPane();
  1588. jTextArea1 = new javax.swing.JTextArea();
  1589. jLabel3 = new javax.swing.JLabel();
  1590. jButton4 = new javax.swing.JButton();
  1591. jPasswordField1 = new javax.swing.JPasswordField();
  1592.  
  1593. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  1594.  
  1595. jLabel1.setBackground(new java.awt.Color(255, 0, 0));
  1596. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  1597. jLabel1.setForeground(new java.awt.Color(0, 0, 102));
  1598. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  1599.  
  1600. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1601. jLabel2.setText("Choose File");
  1602.  
  1603. jButton2.setBackground(new java.awt.Color(204, 204, 255));
  1604. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1605. jButton2.setForeground(new java.awt.Color(0, 0, 204));
  1606. jButton2.setText("Browse");
  1607. jButton2.addActionListener(new java.awt.event.ActionListener() {
  1608. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1609. jButton2ActionPerformed(evt);
  1610. }
  1611. });
  1612.  
  1613. jButton1.setBackground(new java.awt.Color(102, 0, 204));
  1614. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1615. jButton1.setForeground(new java.awt.Color(255, 255, 0));
  1616. jButton1.setText("Requested Key");
  1617. jButton1.addActionListener(new java.awt.event.ActionListener() {
  1618. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1619. jButton1ActionPerformed(evt);
  1620. }
  1621. });
  1622.  
  1623. jButton3.setBackground(new java.awt.Color(0, 102, 102));
  1624. jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1625. jButton3.setForeground(new java.awt.Color(0, 255, 153));
  1626. jButton3.setText("Get-Key");
  1627. jButton3.addActionListener(new java.awt.event.ActionListener() {
  1628. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1629. jButton3ActionPerformed(evt);
  1630. }
  1631. });
  1632.  
  1633. jTextArea1.setColumns(20);
  1634. jTextArea1.setRows(5);
  1635. 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
  1636. jScrollPane1.setViewportView(jTextArea1);
  1637.  
  1638. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  1639. jPanel1.setLayout(jPanel1Layout);
  1640. jPanel1Layout.setHorizontalGroup(
  1641. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1642. .addGroup(jPanel1Layout.createSequentialGroup()
  1643. .addGap(19, 19, 19)
  1644. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE)
  1645. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1646. );
  1647. jPanel1Layout.setVerticalGroup(
  1648. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1649. .addGroup(jPanel1Layout.createSequentialGroup()
  1650. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
  1651. .addGap(0, 0, Short.MAX_VALUE))
  1652. );
  1653.  
  1654. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1655. jLabel3.setText("Public Key");
  1656.  
  1657. jButton4.setBackground(new java.awt.Color(153, 255, 153));
  1658. jButton4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  1659. jButton4.setForeground(new java.awt.Color(0, 153, 153));
  1660. jButton4.setText("Encrypt-Data");
  1661. jButton4.addActionListener(new java.awt.event.ActionListener() {
  1662. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1663. jButton4ActionPerformed(evt);
  1664. }
  1665. });
  1666.  
  1667. jPasswordField1.setEditable(false);
  1668.  
  1669. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1670. getContentPane().setLayout(layout);
  1671. layout.setHorizontalGroup(
  1672. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1673. .addGroup(layout.createSequentialGroup()
  1674. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1675. .addGroup(layout.createSequentialGroup()
  1676. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  1677. .addGroup(layout.createSequentialGroup()
  1678. .addGap(42, 42, 42)
  1679. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1680. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  1681. .addGap(143, 143, 143)
  1682. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
  1683. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  1684. .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  1685. .addGap(55, 55, 55)
  1686. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)))
  1687. .addGap(18, 18, 18)
  1688. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  1689. .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  1690. .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  1691. .addGroup(layout.createSequentialGroup()
  1692. .addGap(158, 158, 158)
  1693. .addComponent(jLabel3)
  1694. .addGap(27, 27, 27)
  1695. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
  1696. .addGap(33, 33, 33)
  1697. .addComponent(jButton4))
  1698. .addGroup(layout.createSequentialGroup()
  1699. .addGap(57, 57, 57)
  1700. .addComponent(jLabel1)))
  1701. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1702. );
  1703. layout.setVerticalGroup(
  1704. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1705. .addGroup(layout.createSequentialGroup()
  1706. .addGap(40, 40, 40)
  1707. .addComponent(jLabel1)
  1708. .addGap(50, 50, 50)
  1709. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1710. .addComponent(jLabel2)
  1711. .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1712. .addComponent(jButton2))
  1713. .addGap(35, 35, 35)
  1714. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1715. .addGroup(layout.createSequentialGroup()
  1716. .addGap(66, 66, 66)
  1717. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
  1718. .addGap(48, 48, 48)
  1719. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
  1720. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1721. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
  1722. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1723. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1724. .addComponent(jLabel3)
  1725. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
  1726. .addGap(43, 43, 43))
  1727. );
  1728.  
  1729. pack();
  1730. }// </editor-fold>//GEN-END:initComponents
  1731.  
  1732. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  1733. // TODO add your handling code here:
  1734. try{
  1735. Connection con=database.getConnection();
  1736. PreparedStatement pst=con.prepareStatement("select *from key_");
  1737.  
  1738. ResultSet r=pst.executeQuery();
  1739. if(r.next()){
  1740. System.out.println(r.getString(1));
  1741. jPasswordField1.setText(r.getString(1));
  1742. }
  1743. // dispose();
  1744. }catch(Exception e){
  1745. e.printStackTrace();
  1746. }
  1747.  
  1748. }//GEN-LAST:event_jButton3ActionPerformed
  1749.  
  1750. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  1751. // TODO add your handling code here:
  1752. RequestedKey rk=new RequestedKey();
  1753. rk.setVisible(true);
  1754.  
  1755.  
  1756.  
  1757. }//GEN-LAST:event_jButton1ActionPerformed
  1758.  
  1759. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  1760. // TODO add your handling code here:
  1761. File f=null;
  1762. String st=null;
  1763. FileInputStream fin=null,files=null;
  1764. FileDialog fd1=new FileDialog(this,"OPEN",FileDialog.LOAD);
  1765. fd1.setVisible(true);
  1766. f4=fd1.getFile();
  1767. filesel=fd1.getDirectory()+fd1.getFile();
  1768. jTextField2.setText(filesel);
  1769. try{
  1770. f=new File(filesel);
  1771. int sz,sz1;
  1772. byte[] buffer;
  1773.  
  1774.  
  1775.  
  1776. fin=new FileInputStream(filesel);
  1777. int filesize=fin.available();
  1778.  
  1779. buffer=new byte[filesize];
  1780.  
  1781. for(int i=0;i<7;i++)
  1782. {
  1783.  
  1784. fin.read(buffer);
  1785. st=new String(buffer);
  1786. }
  1787. jTextArea1.append(st);
  1788.  
  1789. }
  1790. catch(Exception e){
  1791. e.printStackTrace();
  1792. }
  1793.  
  1794.  
  1795.  
  1796. }//GEN-LAST:event_jButton2ActionPerformed
  1797.  
  1798. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  1799. // TODO add your handling code here:
  1800. try{ File f1=new File(filesel);
  1801. FileInputStream files=new FileInputStream(filesel);
  1802. Connection con=database.getConnection();
  1803. PreparedStatement pst=con.prepareStatement("insert into storenode(fname,fdata,keyss) values(?,AES_ENCRYPT(?,'"+jPasswordField1.getText()+"'),'"+jPasswordField1.getText()+"')");
  1804. pst.setString(1,f4);
  1805. pst.setBinaryStream(2,(InputStream)files,(int)(f1.length()));
  1806.  
  1807. int r=pst.executeUpdate();
  1808. if(r==1){
  1809. System.out.println(r);
  1810.  
  1811. EncryptData en=new EncryptData(f4);
  1812. en.setVisible(true);
  1813. dispose();
  1814. }
  1815. // dispose();
  1816. }catch(Exception e){
  1817. e.printStackTrace();
  1818. }
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826. }//GEN-LAST:event_jButton4ActionPerformed
  1827.  
  1828. /**
  1829. * @param args the command line arguments
  1830. */
  1831. public static void main(String args[]) {
  1832. /* Set the Nimbus look and feel */
  1833. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  1834. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  1835. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  1836. */
  1837. try {
  1838. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  1839. if ("Nimbus".equals(info.getName())) {
  1840. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  1841. break;
  1842. }
  1843. }
  1844. } catch (ClassNotFoundException ex) {
  1845. java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1846. } catch (InstantiationException ex) {
  1847. java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1848. } catch (IllegalAccessException ex) {
  1849. java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1850. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  1851. java.util.logging.Logger.getLogger(Sender.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1852. }
  1853. //</editor-fold>
  1854.  
  1855. /* Create and display the form */
  1856. java.awt.EventQueue.invokeLater(new Runnable() {
  1857. public void run() {
  1858. new Sender().setVisible(true);
  1859. }
  1860. });
  1861. }
  1862. // Variables declaration - do not modify//GEN-BEGIN:variables
  1863. private javax.swing.JButton jButton1;
  1864. private javax.swing.JButton jButton2;
  1865. private javax.swing.JButton jButton3;
  1866. private javax.swing.JButton jButton4;
  1867. private javax.swing.JLabel jLabel1;
  1868. private javax.swing.JLabel jLabel2;
  1869. private javax.swing.JLabel jLabel3;
  1870. private javax.swing.JPanel jPanel1;
  1871. private javax.swing.JPasswordField jPasswordField1;
  1872. private javax.swing.JScrollPane jScrollPane1;
  1873. private javax.swing.JTextArea jTextArea1;
  1874. private javax.swing.JTextField jTextField2;
  1875. // End of variables declaration//GEN-END:variables
  1876. }
  1877. -------------------------------------------------------STORAGE NODE-----------------------------------------------
  1878. /*
  1879. * To change this template, choose Tools | Templates
  1880. * and open the template in the editor.
  1881. */
  1882. package ABE;
  1883.  
  1884. import java.awt.Color;
  1885. import javax.swing.JFrame;
  1886.  
  1887. /**
  1888. *
  1889. * @author ali
  1890. */
  1891. public class StorageNode extends javax.swing.JFrame {
  1892.  
  1893. /**
  1894. * Creates new form StorageNode
  1895. */
  1896. public StorageNode() {
  1897. initComponents();
  1898. this.getContentPane().setBackground(Color.yellow);
  1899. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  1900. this.setTitle("Storage_Node");
  1901. this.setResizable(false);
  1902. }
  1903.  
  1904. /**
  1905. * This method is called from within the constructor to initialize the form.
  1906. * WARNING: Do NOT modify this code. The content of this method is always
  1907. * regenerated by the Form Editor.
  1908. */
  1909. @SuppressWarnings("unchecked")
  1910. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  1911. private void initComponents() {
  1912.  
  1913. jLabel1 = new javax.swing.JLabel();
  1914. jLabel2 = new javax.swing.JLabel();
  1915. jButton1 = new javax.swing.JButton();
  1916.  
  1917. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  1918.  
  1919. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  1920. jLabel2.setForeground(new java.awt.Color(51, 51, 0));
  1921. jLabel2.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  1922.  
  1923. jButton1.setBackground(new java.awt.Color(51, 51, 0));
  1924. jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/node.png"))); // NOI18N
  1925. jButton1.addActionListener(new java.awt.event.ActionListener() {
  1926. public void actionPerformed(java.awt.event.ActionEvent evt) {
  1927. jButton1ActionPerformed(evt);
  1928. }
  1929. });
  1930.  
  1931. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1932. getContentPane().setLayout(layout);
  1933. layout.setHorizontalGroup(
  1934. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1935. .addGroup(layout.createSequentialGroup()
  1936. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1937. .addGroup(layout.createSequentialGroup()
  1938. .addGap(221, 221, 221)
  1939. .addComponent(jLabel1))
  1940. .addGroup(layout.createSequentialGroup()
  1941. .addGap(24, 24, 24)
  1942. .addComponent(jLabel2))
  1943. .addGroup(layout.createSequentialGroup()
  1944. .addGap(135, 135, 135)
  1945. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)))
  1946. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1947. );
  1948. layout.setVerticalGroup(
  1949. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1950. .addGroup(layout.createSequentialGroup()
  1951. .addGap(39, 39, 39)
  1952. .addComponent(jLabel2)
  1953. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  1954. .addComponent(jLabel1)
  1955. .addGap(18, 18, 18)
  1956. .addComponent(jButton1)
  1957. .addContainerGap(73, Short.MAX_VALUE))
  1958. );
  1959.  
  1960. pack();
  1961. }// </editor-fold>//GEN-END:initComponents
  1962.  
  1963. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  1964. // TODO add your handling code here:
  1965. FilesDetails f=new FilesDetails();
  1966. f.pack();
  1967. f.setVisible(true);
  1968.  
  1969. }//GEN-LAST:event_jButton1ActionPerformed
  1970.  
  1971. /**
  1972. * @param args the command line arguments
  1973. */
  1974. public static void main(String args[]) {
  1975. /* Set the Nimbus look and feel */
  1976. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  1977. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  1978. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  1979. */
  1980. try {
  1981. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  1982. if ("Nimbus".equals(info.getName())) {
  1983. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  1984. break;
  1985. }
  1986. }
  1987. } catch (ClassNotFoundException ex) {
  1988. java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1989. } catch (InstantiationException ex) {
  1990. java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1991. } catch (IllegalAccessException ex) {
  1992. java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1993. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  1994. java.util.logging.Logger.getLogger(StorageNode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  1995. }
  1996. //</editor-fold>
  1997.  
  1998. /* Create and display the form */
  1999. java.awt.EventQueue.invokeLater(new Runnable() {
  2000. public void run() {
  2001. new StorageNode().setVisible(true);
  2002. }
  2003. });
  2004. }
  2005. // Variables declaration - do not modify//GEN-BEGIN:variables
  2006. private javax.swing.JButton jButton1;
  2007. private javax.swing.JLabel jLabel1;
  2008. private javax.swing.JLabel jLabel2;
  2009. // End of variables declaration//GEN-END:variables
  2010. }
  2011. -----------------------------------------------------USER HOME----------------------------------------------
  2012. /*
  2013. * To change this template, choose Tools | Templates
  2014. * and open the template in the editor.
  2015. */
  2016. package ABE;
  2017.  
  2018. import java.awt.Color;
  2019. import java.sql.Connection;
  2020. import java.sql.ResultSet;
  2021. import java.sql.Statement;
  2022. import javax.swing.DefaultListModel;
  2023. import javax.swing.JFrame;
  2024. import javax.swing.JOptionPane;
  2025.  
  2026. /**
  2027. *
  2028. * @author ali
  2029. */
  2030. public class User_Home extends javax.swing.JFrame {
  2031.  
  2032. /**
  2033. * Creates new form User_Home
  2034. */ byte b[];
  2035.  
  2036. String skey=null;
  2037. String fname=null;
  2038. String unm=null;
  2039. public User_Home(String unm) {
  2040. initComponents();
  2041. this.getContentPane().setBackground(Color.CYAN);
  2042. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  2043. this.setTitle("User-Home");
  2044. this.setResizable(false);
  2045. this.unm=unm;
  2046. DefaultListModel dlm=new DefaultListModel();
  2047. try{
  2048. Connection con=database.getConnection();
  2049. Statement st=con.createStatement();
  2050. Statement st1=con.createStatement();Statement st2=con.createStatement();
  2051. String aces="";
  2052. ResultSet r2=st2.executeQuery("select access from signup where unm='"+unm+"'");
  2053. if(r2.next())
  2054. {
  2055. aces=r2.getString(1);
  2056. }
  2057. ResultSet r=st.executeQuery("select fname,access from storenode");
  2058. while(r.next())
  2059. {
  2060. String a=String.valueOf(aces.charAt(0))+String.valueOf(aces.charAt(1));
  2061. String b=String.valueOf(r.getString(2).charAt(0))+String.valueOf(r.getString(2).charAt(1));
  2062. System.out.println("a="+String.valueOf(aces.charAt(0)));
  2063. System.out.println("b="+String.valueOf(r.getString(2).charAt(0)));
  2064. if(a.equals(b)){
  2065. dlm.addElement(r.getString(1));
  2066. }
  2067.  
  2068.  
  2069. }
  2070. jList1.setModel(dlm);
  2071.  
  2072. }catch(Exception e){
  2073. e.printStackTrace();
  2074. }
  2075.  
  2076.  
  2077. }
  2078.  
  2079. /**
  2080. * This method is called from within the constructor to initialize the form.
  2081. * WARNING: Do NOT modify this code. The content of this method is always
  2082. * regenerated by the Form Editor.
  2083. */
  2084. @SuppressWarnings("unchecked")
  2085. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  2086. private void initComponents() {
  2087.  
  2088. jLabel1 = new javax.swing.JLabel();
  2089. jScrollPane1 = new javax.swing.JScrollPane();
  2090. jList1 = new javax.swing.JList();
  2091. jButton1 = new javax.swing.JButton();
  2092. jScrollPane2 = new javax.swing.JScrollPane();
  2093. jTextArea1 = new javax.swing.JTextArea();
  2094. jLabel2 = new javax.swing.JLabel();
  2095. jButton2 = new javax.swing.JButton();
  2096. jButton3 = new javax.swing.JButton();
  2097. jPasswordField1 = new javax.swing.JPasswordField();
  2098. jButton4 = new javax.swing.JButton();
  2099.  
  2100. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  2101.  
  2102. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  2103. jLabel1.setForeground(new java.awt.Color(255, 51, 0));
  2104. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  2105.  
  2106. 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
  2107. jList1.setModel(new javax.swing.AbstractListModel() {
  2108. String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
  2109. public int getSize() { return strings.length; }
  2110. public Object getElementAt(int i) { return strings[i]; }
  2111. });
  2112. jScrollPane1.setViewportView(jList1);
  2113.  
  2114. jButton1.setBackground(new java.awt.Color(51, 204, 0));
  2115. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2116. jButton1.setForeground(new java.awt.Color(102, 102, 102));
  2117. jButton1.setText("View");
  2118. jButton1.addActionListener(new java.awt.event.ActionListener() {
  2119. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2120. jButton1ActionPerformed(evt);
  2121. }
  2122. });
  2123.  
  2124. jTextArea1.setEditable(false);
  2125. jTextArea1.setColumns(20);
  2126. jTextArea1.setRows(5);
  2127. jScrollPane2.setViewportView(jTextArea1);
  2128.  
  2129. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2130. jLabel2.setText("SecretKey");
  2131.  
  2132. jButton2.setBackground(new java.awt.Color(204, 51, 0));
  2133. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2134. jButton2.setText("GetKey");
  2135. jButton2.addActionListener(new java.awt.event.ActionListener() {
  2136. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2137. jButton2ActionPerformed(evt);
  2138. }
  2139. });
  2140.  
  2141. jButton3.setBackground(new java.awt.Color(51, 51, 51));
  2142. jButton3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2143. jButton3.setText("Decrypt-Data");
  2144. jButton3.addActionListener(new java.awt.event.ActionListener() {
  2145. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2146. jButton3ActionPerformed(evt);
  2147. }
  2148. });
  2149.  
  2150. jPasswordField1.setEditable(false);
  2151.  
  2152. jButton4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2153. jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pr1.png"))); // NOI18N
  2154. jButton4.addActionListener(new java.awt.event.ActionListener() {
  2155. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2156. jButton4ActionPerformed(evt);
  2157. }
  2158. });
  2159.  
  2160. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  2161. getContentPane().setLayout(layout);
  2162. layout.setHorizontalGroup(
  2163. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2164. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2165. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  2166. .addComponent(jButton3)
  2167. .addGap(208, 208, 208))
  2168. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2169. .addGap(18, 18, 18)
  2170. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
  2171. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  2172. .addComponent(jLabel2)
  2173. .addGap(18, 18, 18)
  2174. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
  2175. .addGap(18, 18, 18)
  2176. .addComponent(jButton2)
  2177. .addGap(75, 75, 75))
  2178. .addGroup(layout.createSequentialGroup()
  2179. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2180. .addGroup(layout.createSequentialGroup()
  2181. .addGap(47, 47, 47)
  2182. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
  2183. .addGap(38, 38, 38))
  2184. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2185. .addContainerGap()
  2186. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
  2187. .addGap(31, 31, 31)))
  2188. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 370, javax.swing.GroupLayout.PREFERRED_SIZE)
  2189. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  2190. .addGroup(layout.createSequentialGroup()
  2191. .addGap(22, 22, 22)
  2192. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE)
  2193. .addContainerGap())
  2194. );
  2195. layout.setVerticalGroup(
  2196. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2197. .addGroup(layout.createSequentialGroup()
  2198. .addGap(37, 37, 37)
  2199. .addComponent(jLabel1)
  2200. .addGap(48, 48, 48)
  2201. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  2202. .addGroup(layout.createSequentialGroup()
  2203. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
  2204. .addGap(34, 34, 34))
  2205. .addGroup(layout.createSequentialGroup()
  2206. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  2207. .addGap(18, 18, 18)
  2208. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2209. .addGap(31, 31, 31)))
  2210. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2211. .addComponent(jButton1)
  2212. .addComponent(jButton2)
  2213. .addComponent(jLabel2)
  2214. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  2215. .addGap(18, 18, 18)
  2216. .addComponent(jButton3)
  2217. .addContainerGap(47, Short.MAX_VALUE))
  2218. );
  2219.  
  2220. pack();
  2221. }// </editor-fold>//GEN-END:initComponents
  2222.  
  2223. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  2224. // TODO add your handling code here:
  2225. String b1,r1,aces=null;
  2226. fname= (String) jList1.getSelectedValue();
  2227. // System.out.print(s);
  2228. try{
  2229. Connection con1=database.getConnection();
  2230.  
  2231. Statement st1=con1.createStatement();
  2232. Statement st2=con1.createStatement();
  2233. ResultSet r2=st2.executeQuery("select access from signup where unm='"+unm+"'");
  2234.  
  2235. if(r2.next()){
  2236. aces=r2.getString(1);
  2237.  
  2238. }
  2239.  
  2240. Statement s3=con1.createStatement();
  2241. ResultSet rs4=s3.executeQuery("select *from signup where unm='"+unm+"' and status='Revoked'");
  2242. if(!(rs4.next()))
  2243. {
  2244.  
  2245.  
  2246. Statement st3=con1.createStatement();
  2247. ResultSet r4=st3.executeQuery("select *from storenode where fname='"+fname+"' and access='"+aces+"'");
  2248. if(r4.next())
  2249. {
  2250. ResultSet r3=st1.executeQuery("select fdata from storenode where fname='"+fname+"'");
  2251.  
  2252. while(r3.next())
  2253. {
  2254.  
  2255. b=r3.getBytes(1);
  2256. }
  2257. String data=new String(b);
  2258. jTextArea1.setText("");
  2259. jTextArea1.append(data);
  2260.  
  2261. }
  2262. else{
  2263. JOptionPane.showMessageDialog(null,"You Can not Access this File","Warning",JOptionPane.WARNING_MESSAGE);
  2264. }
  2265. }
  2266. else{
  2267. JOptionPane.showMessageDialog(null,"Your Revoked and You Can not Access this File","Warning",JOptionPane.WARNING_MESSAGE);
  2268.  
  2269. }
  2270. }catch(Exception e){
  2271. e.printStackTrace();
  2272. }
  2273.  
  2274.  
  2275.  
  2276. }//GEN-LAST:event_jButton1ActionPerformed
  2277.  
  2278. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  2279.  
  2280. try{
  2281. Connection con1=database.getConnection();
  2282.  
  2283. Statement st1=con1.createStatement();
  2284. if(jTextArea1.getText().equals("")){
  2285. JOptionPane.showMessageDialog(null,"Please First View the File");
  2286.  
  2287. }else{
  2288.  
  2289. ResultSet r1=st1.executeQuery("select keyss from storenode where fname='"+fname+"'");
  2290.  
  2291. if(r1.next())
  2292. {
  2293. skey=r1.getString(1);
  2294. jPasswordField1.setText(skey);
  2295. }
  2296.  
  2297. }
  2298. }catch(Exception e){
  2299. e.printStackTrace();
  2300. }
  2301.  
  2302.  
  2303. }//GEN-LAST:event_jButton2ActionPerformed
  2304.  
  2305. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  2306. // TODO add your handling code here:
  2307.  
  2308. try{
  2309. Connection con1=database.getConnection();
  2310.  
  2311. Statement st1=con1.createStatement();
  2312.  
  2313. if(jPasswordField1.getText().equals("")){
  2314.  
  2315. JOptionPane.showMessageDialog(null,"Please Enter Key");
  2316. }else{
  2317. ResultSet r1=st1.executeQuery("select AES_DECRYPT(fdata,'"+jPasswordField1.getText()+"')from storenode where fname='"+fname+"'");
  2318. System.out.println("r1="+r1);
  2319. if(r1.next())
  2320. {
  2321. System.out.print("k2");
  2322. b=r1.getBytes(1);
  2323. if(b==null)
  2324. {
  2325. JOptionPane.showMessageDialog(null,
  2326. "Please Enter Valid Secret-Key",
  2327. "Error",
  2328. JOptionPane.ERROR_MESSAGE);
  2329. }
  2330. else{
  2331. DecryptData dd=new DecryptData(fname,jPasswordField1.getText());
  2332. dd.setVisible(true);
  2333.  
  2334. }
  2335. }
  2336. }}
  2337. catch(Exception e){
  2338. e.printStackTrace();
  2339. }
  2340.  
  2341.  
  2342. }//GEN-LAST:event_jButton3ActionPerformed
  2343.  
  2344. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  2345. // TODO add your handling code here:
  2346. Profile frame= new Profile(unm);
  2347.  
  2348. frame.pack();
  2349. frame.setVisible(true);
  2350.  
  2351.  
  2352. }//GEN-LAST:event_jButton4ActionPerformed
  2353.  
  2354. /**
  2355. * @param args the command line arguments
  2356. */
  2357. public static void main(String args[]) {
  2358. /* Set the Nimbus look and feel */
  2359. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  2360. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  2361. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  2362. */
  2363. try {
  2364. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  2365. if ("Nimbus".equals(info.getName())) {
  2366. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  2367. break;
  2368. }
  2369. }
  2370. } catch (ClassNotFoundException ex) {
  2371. java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2372. } catch (InstantiationException ex) {
  2373. java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2374. } catch (IllegalAccessException ex) {
  2375. java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2376. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  2377. java.util.logging.Logger.getLogger(User_Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2378. }
  2379. //</editor-fold>
  2380.  
  2381. /* Create and display the form */
  2382. java.awt.EventQueue.invokeLater(new Runnable() {
  2383. public void run() {
  2384. new User_Home("k").setVisible(true);
  2385. }
  2386. });
  2387. }
  2388. // Variables declaration - do not modify//GEN-BEGIN:variables
  2389. private javax.swing.JButton jButton1;
  2390. private javax.swing.JButton jButton2;
  2391. private javax.swing.JButton jButton3;
  2392. private javax.swing.JButton jButton4;
  2393. private javax.swing.JLabel jLabel1;
  2394. private javax.swing.JLabel jLabel2;
  2395. private javax.swing.JList jList1;
  2396. private javax.swing.JPasswordField jPasswordField1;
  2397. private javax.swing.JScrollPane jScrollPane1;
  2398. private javax.swing.JScrollPane jScrollPane2;
  2399. private javax.swing.JTextArea jTextArea1;
  2400. // End of variables declaration//GEN-END:variables
  2401. }
  2402. -------------------------------------------------------USER LOGIN----------------------------------------
  2403. /*
  2404. * To change this template, choose Tools | Templates
  2405. * and open the template in the editor.
  2406. */
  2407. package ABE;
  2408.  
  2409. import java.awt.Color;
  2410. import java.awt.Panel;
  2411. import java.sql.Connection;
  2412. import java.sql.ResultSet;
  2413. import java.sql.Statement;
  2414. import javax.swing.JFrame;
  2415. import javax.swing.JOptionPane;
  2416.  
  2417. /**
  2418. *
  2419. * @author ali
  2420. */
  2421. public class User_Login extends javax.swing.JFrame {
  2422.  
  2423. /**
  2424. * Creates new form User_Home
  2425. */
  2426. public User_Login () {
  2427. initComponents();
  2428.  
  2429. this.getContentPane().setBackground(Color.PINK);
  2430. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  2431. this.setTitle("User-Login");
  2432. this.setResizable(false);
  2433. }
  2434.  
  2435. /**
  2436. * This method is called from within the constructor to initialize the form.
  2437. * WARNING: Do NOT modify this code. The content of this method is always
  2438. * regenerated by the Form Editor.
  2439. */
  2440. @SuppressWarnings("unchecked")
  2441. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  2442. private void initComponents() {
  2443.  
  2444. jMenuItem1 = new javax.swing.JMenuItem();
  2445. jLabel1 = new javax.swing.JLabel();
  2446. jLabel2 = new javax.swing.JLabel();
  2447. jTextField1 = new javax.swing.JTextField();
  2448. jLabel3 = new javax.swing.JLabel();
  2449. jButton1 = new javax.swing.JButton();
  2450. jButton2 = new javax.swing.JButton();
  2451. jPasswordField1 = new javax.swing.JPasswordField();
  2452. jLabel4 = new javax.swing.JLabel();
  2453. jLabel5 = new javax.swing.JLabel();
  2454.  
  2455. jMenuItem1.setText("jMenuItem1");
  2456.  
  2457. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  2458. setBackground(new java.awt.Color(102, 0, 102));
  2459.  
  2460. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  2461. jLabel1.setForeground(new java.awt.Color(51, 51, 0));
  2462. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  2463.  
  2464. jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2465. jLabel2.setForeground(new java.awt.Color(0, 0, 153));
  2466. jLabel2.setText("Usename");
  2467.  
  2468. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2469. jLabel3.setForeground(new java.awt.Color(0, 0, 153));
  2470. jLabel3.setText("Password");
  2471.  
  2472. jButton1.setBackground(new java.awt.Color(0, 102, 0));
  2473. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2474. jButton1.setForeground(new java.awt.Color(255, 255, 255));
  2475. jButton1.setText("Login");
  2476. jButton1.addActionListener(new java.awt.event.ActionListener() {
  2477. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2478. jButton1ActionPerformed(evt);
  2479. }
  2480. });
  2481.  
  2482. jButton2.setBackground(new java.awt.Color(153, 51, 0));
  2483. jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2484. jButton2.setForeground(new java.awt.Color(0, 0, 51));
  2485. jButton2.setText("NewUser");
  2486. jButton2.addActionListener(new java.awt.event.ActionListener() {
  2487. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2488. jButton2ActionPerformed(evt);
  2489. }
  2490. });
  2491.  
  2492. jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/lgn.jpg"))); // NOI18N
  2493.  
  2494. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  2495. getContentPane().setLayout(layout);
  2496. layout.setHorizontalGroup(
  2497. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2498. .addGroup(layout.createSequentialGroup()
  2499. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2500. .addGroup(layout.createSequentialGroup()
  2501. .addGap(18, 18, 18)
  2502. .addComponent(jLabel1))
  2503. .addGroup(layout.createSequentialGroup()
  2504. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2505. .addGroup(layout.createSequentialGroup()
  2506. .addGap(52, 52, 52)
  2507. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2508. .addComponent(jLabel2)
  2509. .addComponent(jLabel3))
  2510. .addGap(45, 45, 45)
  2511. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  2512. .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
  2513. .addComponent(jPasswordField1))
  2514. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  2515. .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  2516. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
  2517. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2518. .addContainerGap()
  2519. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
  2520. .addGap(90, 90, 90)))
  2521. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2522. .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
  2523. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2524. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
  2525. .addGap(100, 100, 100)))))
  2526. .addContainerGap(19, Short.MAX_VALUE))
  2527. );
  2528. layout.setVerticalGroup(
  2529. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2530. .addGroup(layout.createSequentialGroup()
  2531. .addGap(28, 28, 28)
  2532. .addComponent(jLabel1)
  2533. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2534. .addGroup(layout.createSequentialGroup()
  2535. .addGap(81, 81, 81)
  2536. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2537. .addComponent(jLabel2)
  2538. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2539. .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
  2540. .addGap(60, 60, 60)
  2541. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  2542. .addComponent(jLabel3)
  2543. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  2544. .addGroup(layout.createSequentialGroup()
  2545. .addGap(50, 50, 50)
  2546. .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)))
  2547. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2548. .addGroup(layout.createSequentialGroup()
  2549. .addGap(18, 18, 18)
  2550. .addComponent(jButton2))
  2551. .addGroup(layout.createSequentialGroup()
  2552. .addGap(4, 4, 4)
  2553. .addComponent(jButton1)))
  2554. .addContainerGap(69, Short.MAX_VALUE))
  2555. );
  2556.  
  2557. pack();
  2558. }// </editor-fold>//GEN-END:initComponents
  2559.  
  2560. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  2561. // TODO add your handling code here:
  2562. String unm=jTextField1.getText();
  2563. String pwd=jPasswordField1.getText();
  2564. try{
  2565. Connection con=database.getConnection();
  2566. Statement st=con.createStatement();
  2567. Statement st1=con.createStatement();
  2568. ResultSet r=st.executeQuery("select *from signup where unm='"+unm+"' and pwd='"+pwd+"'");
  2569. if(r.next())
  2570. {
  2571. User_Home uhm=new User_Home(unm);
  2572. uhm.setVisible(true);
  2573. dispose();
  2574. }
  2575. else{
  2576. JOptionPane.showMessageDialog(null,"Incorrect either Username or Password","Error",JOptionPane.ERROR_MESSAGE);
  2577. }
  2578. }catch(Exception e){
  2579. e.printStackTrace();
  2580. }
  2581. }//GEN-LAST:event_jButton1ActionPerformed
  2582.  
  2583. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  2584. // TODO add your handling code here:
  2585. User_Reg ureg=new User_Reg();
  2586. ureg.setVisible(true);
  2587. }//GEN-LAST:event_jButton2ActionPerformed
  2588.  
  2589. /**
  2590. * @param args the command line arguments
  2591. */
  2592. public static void main(String args[]) {
  2593. /* Set the Nimbus look and feel */
  2594. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  2595. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  2596. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  2597. */
  2598. try {
  2599. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  2600. if ("Nimbus".equals(info.getName())) {
  2601. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  2602. break;
  2603. }
  2604. }
  2605. } catch (ClassNotFoundException ex) {
  2606. java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2607. } catch (InstantiationException ex) {
  2608. java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2609. } catch (IllegalAccessException ex) {
  2610. java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2611. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  2612. java.util.logging.Logger.getLogger(User_Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2613. }
  2614. //</editor-fold>
  2615.  
  2616. /* Create and display the form */
  2617. java.awt.EventQueue.invokeLater(new Runnable() {
  2618. public void run() {
  2619. new User_Login().setVisible(true);
  2620. }
  2621. });
  2622. }
  2623. // Variables declaration - do not modify//GEN-BEGIN:variables
  2624. private javax.swing.JButton jButton1;
  2625. private javax.swing.JButton jButton2;
  2626. private javax.swing.JLabel jLabel1;
  2627. private javax.swing.JLabel jLabel2;
  2628. private javax.swing.JLabel jLabel3;
  2629. private javax.swing.JLabel jLabel4;
  2630. private javax.swing.JLabel jLabel5;
  2631. private javax.swing.JMenuItem jMenuItem1;
  2632. private javax.swing.JPasswordField jPasswordField1;
  2633. private javax.swing.JTextField jTextField1;
  2634. // End of variables declaration//GEN-END:variables
  2635. }
  2636. ---------------------------------------------------USER REGISTRATION---------------------------------------
  2637. /*
  2638. * To change this template, choose Tools | Templates
  2639. * and open the template in the editor.
  2640. */
  2641. package ABE;
  2642.  
  2643. import java.awt.Color;
  2644. import java.sql.Connection;
  2645. import java.sql.PreparedStatement;
  2646. import javax.swing.JFrame;
  2647. import javax.swing.JOptionPane;
  2648.  
  2649. /**
  2650. *
  2651. * @author ali
  2652. */
  2653. public class User_Reg extends javax.swing.JFrame {
  2654.  
  2655. /**
  2656. * Creates new form User_Reg
  2657. */
  2658. public User_Reg() {
  2659. initComponents();
  2660. this.getContentPane().setBackground(Color.orange);
  2661. this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  2662. this.setTitle("User-Registration");
  2663. this.setResizable(false);
  2664. }
  2665.  
  2666. /**
  2667. * This method is called from within the constructor to initialize the form.
  2668. * WARNING: Do NOT modify this code. The content of this method is always
  2669. * regenerated by the Form Editor.
  2670. */
  2671. @SuppressWarnings("unchecked")
  2672. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  2673. private void initComponents() {
  2674.  
  2675. jInternalFrame1 = new javax.swing.JInternalFrame();
  2676. jLabel1 = new javax.swing.JLabel();
  2677. jLabel2 = new javax.swing.JLabel();
  2678. jLabel3 = new javax.swing.JLabel();
  2679. jLabel4 = new javax.swing.JLabel();
  2680. jLabel5 = new javax.swing.JLabel();
  2681. jLabel6 = new javax.swing.JLabel();
  2682. jLabel7 = new javax.swing.JLabel();
  2683. jTextField1 = new javax.swing.JTextField();
  2684. jTextField3 = new javax.swing.JTextField();
  2685. jComboBox1 = new javax.swing.JComboBox();
  2686. jComboBox2 = new javax.swing.JComboBox();
  2687. jButton1 = new javax.swing.JButton();
  2688. jPasswordField1 = new javax.swing.JPasswordField();
  2689.  
  2690. jInternalFrame1.setVisible(true);
  2691.  
  2692. javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
  2693. jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
  2694. jInternalFrame1Layout.setHorizontalGroup(
  2695. jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2696. .addGap(0, 0, Short.MAX_VALUE)
  2697. );
  2698. jInternalFrame1Layout.setVerticalGroup(
  2699. jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2700. .addGap(0, 0, Short.MAX_VALUE)
  2701. );
  2702.  
  2703. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  2704.  
  2705. jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
  2706. jLabel1.setForeground(new java.awt.Color(0, 102, 102));
  2707. jLabel1.setText("Secure Data Retrieval for Decentralized Disruption-Tolerant Military Networks");
  2708.  
  2709. jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reg.jpg"))); // NOI18N
  2710.  
  2711. jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2712. jLabel3.setText("Username");
  2713.  
  2714. jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2715. jLabel4.setText("Password");
  2716.  
  2717. jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2718. jLabel5.setText("Email-Id");
  2719.  
  2720. jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2721. jLabel6.setText("Battalion");
  2722.  
  2723. jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
  2724. jLabel7.setText("Region");
  2725.  
  2726. jTextField1.addActionListener(new java.awt.event.ActionListener() {
  2727. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2728. jTextField1ActionPerformed(evt);
  2729. }
  2730. });
  2731.  
  2732. jTextField3.addActionListener(new java.awt.event.ActionListener() {
  2733. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2734. jTextField3ActionPerformed(evt);
  2735. }
  2736. });
  2737.  
  2738. jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "B1", "B2" }));
  2739. jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  2740. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2741. jComboBox1ActionPerformed(evt);
  2742. }
  2743. });
  2744.  
  2745. jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "R1", "R2" }));
  2746. jComboBox2.addActionListener(new java.awt.event.ActionListener() {
  2747. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2748. jComboBox2ActionPerformed(evt);
  2749. }
  2750. });
  2751.  
  2752. jButton1.setBackground(new java.awt.Color(0, 0, 102));
  2753. jButton1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
  2754. jButton1.setForeground(new java.awt.Color(0, 255, 255));
  2755. jButton1.setText("Register");
  2756. jButton1.addActionListener(new java.awt.event.ActionListener() {
  2757. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2758. jButton1ActionPerformed(evt);
  2759. }
  2760. });
  2761.  
  2762. jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
  2763. public void actionPerformed(java.awt.event.ActionEvent evt) {
  2764. jPasswordField1ActionPerformed(evt);
  2765. }
  2766. });
  2767.  
  2768. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  2769. getContentPane().setLayout(layout);
  2770. layout.setHorizontalGroup(
  2771. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2772. .addGroup(layout.createSequentialGroup()
  2773. .addGap(79, 79, 79)
  2774. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  2775. .addGroup(layout.createSequentialGroup()
  2776. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2777. .addComponent(jLabel3)
  2778. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  2779. .addComponent(jLabel4)
  2780. .addGap(6, 6, 6)))
  2781. .addGap(84, 84, 84)
  2782. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  2783. .addComponent(jComboBox2, 0, 154, Short.MAX_VALUE)
  2784. .addComponent(jPasswordField1)
  2785. .addComponent(jTextField1)
  2786. .addComponent(jTextField3)
  2787. .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  2788. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  2789. .addComponent(jLabel5)
  2790. .addComponent(jLabel6))
  2791. .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING))
  2792. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  2793. .addComponent(jLabel2)
  2794. .addGap(27, 27, 27))
  2795. .addGroup(layout.createSequentialGroup()
  2796. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2797. .addGroup(layout.createSequentialGroup()
  2798. .addGap(239, 239, 239)
  2799. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
  2800. .addGroup(layout.createSequentialGroup()
  2801. .addGap(54, 54, 54)
  2802. .addComponent(jLabel1)))
  2803. .addContainerGap(59, Short.MAX_VALUE))
  2804. );
  2805. layout.setVerticalGroup(
  2806. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2807. .addGroup(layout.createSequentialGroup()
  2808. .addGap(21, 21, 21)
  2809. .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
  2810. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  2811. .addGroup(layout.createSequentialGroup()
  2812. .addGap(42, 42, 42)
  2813. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2814. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2815. .addComponent(jLabel3))
  2816. .addGap(39, 39, 39)
  2817. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2818. .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2819. .addComponent(jLabel4))
  2820. .addGap(40, 40, 40)
  2821. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2822. .addComponent(jLabel5)
  2823. .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  2824. .addGap(32, 32, 32)
  2825. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2826. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2827. .addComponent(jLabel6)))
  2828. .addGroup(layout.createSequentialGroup()
  2829. .addGap(65, 65, 65)
  2830. .addComponent(jLabel2)))
  2831. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  2832. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  2833. .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  2834. .addComponent(jLabel7))
  2835. .addGap(35, 35, 35)
  2836. .addComponent(jButton1)
  2837. .addGap(79, 79, 79))
  2838. );
  2839.  
  2840. pack();
  2841. }// </editor-fold>//GEN-END:initComponents
  2842.  
  2843. private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
  2844. // TODO add your handling code here:
  2845.  
  2846.  
  2847.  
  2848. }//GEN-LAST:event_jComboBox1ActionPerformed
  2849.  
  2850. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  2851. // TODO add your handling code here:
  2852. String unm=jTextField1.getText();
  2853. String pwd=jPasswordField1.getText();
  2854. String eid=jTextField3.getText();
  2855. String b=jComboBox1.getSelectedItem().toString();
  2856. String r=jComboBox2.getSelectedItem().toString();
  2857. String ap=b+"^"+r;
  2858. String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
  2859. if(unm.equals("")){
  2860.  
  2861. JOptionPane.showMessageDialog(null,"Please Enter Username");
  2862. }else{
  2863.  
  2864. if(pwd.equals("")){
  2865.  
  2866. JOptionPane.showMessageDialog(null,"Please Enter Password");
  2867. }
  2868. else{
  2869.  
  2870. if(eid.equals("")){
  2871.  
  2872. JOptionPane.showMessageDialog(null,"Please Enter Email ID");
  2873. }
  2874. else{
  2875.  
  2876.  
  2877. if(!eid.matches(EMAIL_REGEX)){
  2878. JOptionPane.showMessageDialog(null,"Please Enter Valid Email ID");
  2879.  
  2880. }
  2881.  
  2882. else{
  2883.  
  2884. try{
  2885. Connection con=database.getConnection();
  2886. PreparedStatement pst=con.prepareStatement("insert into signup values(?,?,?,?,?,?,?)");
  2887. pst.setString(1,unm);
  2888. pst.setString(2,pwd);
  2889. pst.setString(3,eid);
  2890. pst.setString(4,b);
  2891. pst.setString(5,r);
  2892. pst.setString(6,ap);
  2893. pst.setString(7,"Non-Revoked");
  2894. int i=pst.executeUpdate();
  2895. if(i==1){
  2896. JOptionPane.showMessageDialog(null,"Registerd Successfully");
  2897. }
  2898. dispose();
  2899.  
  2900.  
  2901. }catch(Exception e){
  2902. e.printStackTrace();
  2903.  
  2904. }
  2905.  
  2906.  
  2907. }
  2908. }
  2909. }}
  2910. }//GEN-LAST:event_jButton1ActionPerformed
  2911.  
  2912. private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
  2913. // TODO add your handling code here:
  2914. }//GEN-LAST:event_jTextField1ActionPerformed
  2915.  
  2916. private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
  2917. // TODO add your handling code here:
  2918. }//GEN-LAST:event_jPasswordField1ActionPerformed
  2919.  
  2920. private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
  2921. // TODO add your handling code here:
  2922. }//GEN-LAST:event_jComboBox2ActionPerformed
  2923.  
  2924. private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
  2925. // TODO add your handling code here:
  2926. }//GEN-LAST:event_jTextField3ActionPerformed
  2927.  
  2928. /**
  2929. * @param args the command line arguments
  2930. */
  2931. public static void main(String args[]) {
  2932. /* Set the Nimbus look and feel */
  2933. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  2934. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  2935. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  2936. */
  2937. try {
  2938. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  2939. if ("Nimbus".equals(info.getName())) {
  2940. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  2941. break;
  2942. }
  2943. }
  2944. } catch (ClassNotFoundException ex) {
  2945. java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2946. } catch (InstantiationException ex) {
  2947. java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2948. } catch (IllegalAccessException ex) {
  2949. java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2950. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  2951. java.util.logging.Logger.getLogger(User_Reg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  2952. }
  2953. //</editor-fold>
  2954.  
  2955. /* Create and display the form */
  2956. java.awt.EventQueue.invokeLater(new Runnable() {
  2957. public void run() {
  2958. new User_Reg().setVisible(true);
  2959. }
  2960. });
  2961. }
  2962. // Variables declaration - do not modify//GEN-BEGIN:variables
  2963. private javax.swing.JButton jButton1;
  2964. private javax.swing.JComboBox jComboBox1;
  2965. private javax.swing.JComboBox jComboBox2;
  2966. private javax.swing.JInternalFrame jInternalFrame1;
  2967. private javax.swing.JLabel jLabel1;
  2968. private javax.swing.JLabel jLabel2;
  2969. private javax.swing.JLabel jLabel3;
  2970. private javax.swing.JLabel jLabel4;
  2971. private javax.swing.JLabel jLabel5;
  2972. private javax.swing.JLabel jLabel6;
  2973. private javax.swing.JLabel jLabel7;
  2974. private javax.swing.JPasswordField jPasswordField1;
  2975. private javax.swing.JTextField jTextField1;
  2976. private javax.swing.JTextField jTextField3;
  2977. // End of variables declaration//GEN-END:variables
  2978. }
  2979. -------------------------------------------------------USER DETAILS-------------------------------------------
  2980. /*
  2981. * To change this template, choose Tools | Templates
  2982. * and open the template in the editor.
  2983. */
  2984. package ABE;
  2985.  
  2986. /**
  2987. *
  2988. * @author ali
  2989. */
  2990.  
  2991. import java.awt.*;
  2992. import java.sql.*;
  2993. import java.util.*;
  2994. import javax.swing.*;
  2995. import javax.swing.table.*;
  2996.  
  2997. public class UserDetails extends JFrame
  2998. {
  2999. public UserDetails (String kauser,String batalion)
  3000. {
  3001. ArrayList columnNames = new ArrayList();
  3002. ArrayList data = new ArrayList();
  3003.  
  3004. // Connect to an MySQL Database, run query, get result set
  3005. String url = "jdbc:mysql://localhost:3306/cp-abe";
  3006. String userid = "root";
  3007. String password = "root";
  3008. String sql = "SELECT * FROM requested where kauser='"+kauser+"' and batalion='"+batalion+"'";
  3009.  
  3010. // Java SE 7 has try-with-resources
  3011. // This will ensure that the sql objects are closed when the program
  3012. // is finished with them
  3013. try {
  3014. Class.forName("com.mysql.jdbc.Driver");
  3015.  
  3016. Connection connection = DriverManager.getConnection( url, userid, password );
  3017. Statement stmt = connection.createStatement();
  3018. ResultSet rs = stmt.executeQuery( sql );
  3019.  
  3020. ResultSetMetaData md = rs.getMetaData();
  3021. int columns = md.getColumnCount();
  3022.  
  3023. // Get column names
  3024. for (int i = 1; i <= columns; i++)
  3025. {
  3026. columnNames.add( md.getColumnName(i) );
  3027. }
  3028.  
  3029. // Get row data
  3030. while (rs.next())
  3031. {
  3032. ArrayList row = new ArrayList(columns);
  3033.  
  3034. for (int i = 1; i <= columns; i++)
  3035. {
  3036. row.add( rs.getObject(i) );
  3037. }
  3038.  
  3039. data.add( row );
  3040. }
  3041. }
  3042. catch (Exception e)
  3043. {
  3044. System.out.println( e.getMessage() );
  3045. }
  3046.  
  3047. // Create Vectors and copy over elements from ArrayLists to them
  3048. // Vector is deprecated but I am using them in this example to keep
  3049. // things simple - the best practice would be to create a custom defined
  3050. // class which inherits from the AbstractTableModel class
  3051. Vector columnNamesVector = new Vector();
  3052. Vector dataVector = new Vector();
  3053.  
  3054. for (int i = 0; i < data.size(); i++)
  3055. {
  3056. ArrayList subArray = (ArrayList)data.get(i);
  3057. Vector subVector = new Vector();
  3058. for (int j = 0; j < subArray.size(); j++)
  3059. {
  3060. subVector.add(subArray.get(j));
  3061. }
  3062. dataVector.add(subVector);
  3063. }
  3064.  
  3065. for (int i = 0; i < columnNames.size(); i++ )
  3066. columnNamesVector.add(columnNames.get(i));
  3067.  
  3068. // Create table with database data
  3069. JTable table = new JTable(dataVector, columnNamesVector)
  3070. {
  3071. public Class getColumnClass(int column)
  3072. {
  3073. for (int row = 0; row < getRowCount(); row++)
  3074. {
  3075. Object o = getValueAt(row, column);
  3076.  
  3077. if (o != null)
  3078. {
  3079. return o.getClass();
  3080. }
  3081. }
  3082.  
  3083. return Object.class;
  3084. }
  3085. };
  3086.  
  3087. JScrollPane scrollPane = new JScrollPane( table );
  3088. getContentPane().add( scrollPane );
  3089.  
  3090. JPanel buttonPanel = new JPanel();
  3091. getContentPane().add( buttonPanel, BorderLayout.SOUTH );
  3092. }
  3093.  
  3094. public static void main(String[] args)
  3095. {
  3096.  
  3097. }
  3098. }
  3099. --------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement