generated from CxOneOrg/CheckmarxDemo
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Login.java
54 lines (46 loc) · 1.51 KB
/
Login.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
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import cnt.Security.*;
import java.lang.StringBuffer;
import java.sql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;
// Class Declaration
class Login
{
public static void main(String[] args)
{
try {
String email = request.getParameter("email");
String token = request.getParameter("password");
String sql = "select * from users where (email ='" + email +"' and password ='" + token + "')";
Connection connection = pool.getConnection();
Statement statement = connection.createStatement();
HttpSession session = request.getSession();
String role = (String)session.getAttribute("role");
if (role.equals(ADMIN)) {
ResultSet result = statement.executeQuery(sql);
statement.close();
connection.close();
}
if (result.next()) {
loggedIn = true;
// Successfully logged in and redirect to user profile page
} else {
// Auth failure - Redirect to Login Page
}
}
catch (SQLException ex) {
handleExceptions(ex);
}
finally {
statement.close();
connection.close();
}
}
}