-
Notifications
You must be signed in to change notification settings - Fork 0
/
Authenticate.java
75 lines (71 loc) · 1.12 KB
/
Authenticate.java
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
import java.io.*;
import jxl.*;
public class Authenticate
{
String login;
String paswd;
//final static String filename="../electionday/check.xls";
Authenticate(String login,String paswd)
{
this.login=login;
this.paswd=paswd;
}
String checkthevalidity()
{
String filename="../registration/check.xls";
System.out.println(login+"\t"+paswd);
Workbook wb=null;
Sheet s=null;
Cell cell=null;
String did=null;
int id=0;
try
{
wb=Workbook.getWorkbook(new File(filename));
s=wb.getSheet(0);
int i=0;
int flag=0;
System.out.println("started searching ...");
for(i=0;i<5;i++)
{
cell=s.getCell(1,i);
String ls=cell.getContents();
if(this.login.equals(ls))
{
System.out.println("finded at"+i);
flag=1;
id=i;
}
}
if(flag==0)
{
System.out.println("not able to findout");
did="not-done";
//return did;
}
else
{
cell=s.getCell(5,id); // dob cell
String lst=cell.getContents();
System.out.println(lst);
if(this.paswd.equals(lst))
{
did="done";
System.out.println("paswd is also validated");
//return did;
}
else
{
System.out.println("passwd isn not validated");
did="not-done";
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
//String did="done";
return did;
}
}