1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
import java.io.*;
import java.util.logging.*;
import javax.swing.JOptionPane;
/*
* Auth.java
*
* Created on 27 mai 2008, 08:50
*/
/**
*
* @author adminlocal
*/
public class Auth extends javax.swing.JFrame {
/** Creates new form Auth */
public Auth() {
initComponents();
GestionSystemeGardien gest = new GestionSystemeGardien();
gest.centrageFenetre(this);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jText_MDP = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jText_ID = new javax.swing.JTextField();
jButtonOK = new javax.swing.JButton();
jButtonAnnuler = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel2.setText("Mot de passe:");
jLabel1.setText("Nom d'utilisateur:");
jText_ID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jText_IDActionPerformed(evt);
}
});
jButtonOK.setText("OK");
jButtonOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonOKActionPerformed(evt);
}
});
jButtonAnnuler.setText("Annuler");
jButtonAnnuler.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAnnulerActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(29, 29, 29)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel2)
.add(18, 18, 18)
.add(jText_MDP, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jText_ID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(jButtonOK, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButtonAnnuler)))
.addContainerGap(36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jText_ID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jText_MDP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButtonAnnuler)
.add(jButtonOK))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButtonAnnulerActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void jText_IDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
identifier();
} catch (FileNotFoundException ex) {
Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void identifier() throws FileNotFoundException, IOException {
String ID = jText_ID.getText().toUpperCase();
String MDP = jText_MDP.getText().toLowerCase();
String chaine = "";
String fin = "";
String temp = "";
String fichier = "c://FicMdp.txt/";
//lecture du fichier texte
InputStream ips = new FileInputStream(fichier);
InputStreamReader ipsr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(ipsr);
String ligne;
while ((ligne = br.readLine()) != null) {
chaine += ligne + "\n";
}
int j = 1;
int i = 0;
String tabInfo[] = {"", ""};
int numvar = 0;
int nbmot = 0;
while (j < chaine.length() + 1) {
temp = chaine.substring(i, j);
if (!temp.equals(" ") && (nbmot < 3)) {
fin += temp;
} else {
tabInfo[numvar] = fin;
fin = "";
nbmot++;
numvar++;
}
i++;
j++;
}
Crypter C = new Crypter();
String l_ID = C.Decrypte(tabInfo[0], 2).toUpperCase();
String l_MDP = C.Decrypte(tabInfo[1], 2).toLowerCase();
if (ID.equals(l_ID) && MDP.equals(l_MDP)) {
new Interface_Gardien().setVisible(true);
this.setVisible(false);
} else {//((!ID.equals("DRH") && !MDP.equals("admin"))) {
JOptionPane.showMessageDialog(null, "Votre identifiant ou mot de passe est invalide", "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Auth().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButtonAnnuler;
private javax.swing.JButton jButtonOK;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jText_ID;
private javax.swing.JPasswordField jText_MDP;
// End of variables declaration
} |
Partager