diff --git a/WebContent/html/webpages/adminpassword.jsp b/WebContent/html/webpages/adminpassword.jsp
new file mode 100644
index 0000000..2be0454
--- /dev/null
+++ b/WebContent/html/webpages/adminpassword.jsp
@@ -0,0 +1,60 @@
+<%@ page import = "database.*,entities.User" %>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+
+
+
+
+
+
+
+
+
+
Synchrony Financial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebContent/html/webpages/adminpasswordchange.jsp b/WebContent/html/webpages/adminpasswordchange.jsp
new file mode 100644
index 0000000..881eb1d
--- /dev/null
+++ b/WebContent/html/webpages/adminpasswordchange.jsp
@@ -0,0 +1,71 @@
+<%@ page import = "database.*,entities.Device" %>
+<%@ page import = "java.sql.*" %>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+
+
+
+
+
+
+
+
+
+
+
Synchrony Financial
+
+
+
+
+
+
+
+
+
+
+
Redirect Page
+
You shouldn't be seeing this page :)
+
+<%
+//add form was submitted
+if(request.getParameter("submit") != null){
+ String old = request.getParameter("old");
+ String newpass = request.getParameter("new");
+ String confirm = request.getParameter("confirm");
+ String pincode = request.getParameter("pincode");
+ String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
+ String user = "b372dfe7409692";
+ String password = "74f6e317";
+ System.getenv("VCAP_SERVICES");
+ Class.forName("com.mysql.jdbc.Driver");
+ Connection connection = DriverManager.getConnection(database, user, password);
+ Statement stmt = connection.createStatement();
+ ResultSet result;
+ result = stmt.executeQuery("select * FROM admin where Admin_ID='" + navsso + "' AND Password='" + old + "'");
+ if(result.next()){//if old password is accurate
+ if (!old.equals(newpass) && newpass.equals(confirm) && pincode.length() == 4 && AdminQueries.pincodeInt(pincode)){//if the password is new AND both news ones are equal AND pincode is 4 digits AND pincode is a number
+ stmt.executeUpdate("UPDATE admin SET Password = \"" + newpass + "\", Password_Flag = 1, Pincode = " + pincode + " WHERE Admin_ID = " + navsso);
+ stmt.close();
+ connection.close();
+ response.sendRedirect("admin.jsp");
+ return;
+ }
+ else{
+ stmt.close();
+ connection.close();
+ response.sendRedirect("adminpasswordtryagain.jsp");
+ return;
+ }
+ }
+ else{
+ stmt.close();
+ connection.close();
+ response.sendRedirect("adminpasswordtryagain.jsp");
+ return;
+ }
+}
+%>
+
+
\ No newline at end of file
diff --git a/WebContent/html/webpages/adminpasswordtryagain.jsp b/WebContent/html/webpages/adminpasswordtryagain.jsp
new file mode 100644
index 0000000..ae7082f
--- /dev/null
+++ b/WebContent/html/webpages/adminpasswordtryagain.jsp
@@ -0,0 +1,61 @@
+<%@ page import = "database.*,entities.User" %>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+
+
+
+
+
+
+
+
+
+
Synchrony Financial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebContent/html/webpages/deviceRedirect.jsp b/WebContent/html/webpages/deviceRedirect.jsp
index d3e9558..08624d8 100644
--- a/WebContent/html/webpages/deviceRedirect.jsp
+++ b/WebContent/html/webpages/deviceRedirect.jsp
@@ -37,7 +37,7 @@ String manufacturer = request.getParameter("manu").replace("\"","\\\"");
String hardware = request.getParameter("hardware").replace("\"","\\\"");
String model = request.getParameter("model").replace("\"","\\\"");
String serial = request.getParameter("serial");
-int nfc = Integer.parseInt(request.getParameter("NFC"));
+String nfc = request.getParameter("NFC");
//add form was submitted
if(request.getParameter("add") != null){
Device device = new Device(name,1,description,hardware,model,manufacturer,status,mac,serial,nfc);
@@ -65,7 +65,5 @@ if(request.getParameter("delete") != null){
-
-
\ No newline at end of file
diff --git a/WebContent/html/webpages/logout.jsp b/WebContent/html/webpages/logout.jsp
new file mode 100644
index 0000000..e39c5f3
--- /dev/null
+++ b/WebContent/html/webpages/logout.jsp
@@ -0,0 +1,22 @@
+<%@ page import = "database.*" %>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%@ page import = "java.sql.*" %>
+
+<%
+Cookie[] usercookies = request.getCookies();
+if(usercookies != null){
+ for(Cookie c : usercookies){
+ if(c.getName().equals("ssoNum") || c.getName().equals("admin")){//when (and if) we get to user cookie we want to reset it
+ c.setMaxAge(0);//delete current
+ String cookiename = c.getName();
+ Cookie newCookie = new Cookie(cookiename,"");//make new one
+ newCookie.setMaxAge(0);
+ newCookie.setPath("/");
+ response.addCookie(newCookie);
+ }
+ }
+}
+response.sendRedirect("index.jsp");
+return;
+%>
\ No newline at end of file
diff --git a/WebContent/html/webpages/navbar.jsp b/WebContent/html/webpages/navbar.jsp
index 4f60228..4ab3fbe 100644
--- a/WebContent/html/webpages/navbar.jsp
+++ b/WebContent/html/webpages/navbar.jsp
@@ -18,10 +18,12 @@
<%
@@ -30,16 +32,22 @@
String navname = "error";
User self = new User();
Cookie newCookie;
+ int admin = 0;
+
//iterate cookies
if(usercookies != null){
for(Cookie c : usercookies){
- if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
+ if(c.getName().equals("ssoNum") || c.getName().equals("admin")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
+ String cookiename = c.getName();
c.setMaxAge(0);//delete current
- newCookie = new Cookie("ssoNum",navsso);//make new one
+ newCookie = new Cookie(cookiename,navsso);//make new one
newCookie.setMaxAge(30*60);
+ newCookie.setPath("/");
response.addCookie(newCookie);
- break;
+ }
+ if(c.getName().equals("admin")){
+ admin = 1;
}
}
}
@@ -56,4 +64,6 @@
\ No newline at end of file
diff --git a/WebContent/html/webpages/returnPage.jsp b/WebContent/html/webpages/returnPage.jsp
index 00c03bc..6d85190 100644
--- a/WebContent/html/webpages/returnPage.jsp
+++ b/WebContent/html/webpages/returnPage.jsp
@@ -12,8 +12,6 @@
Synchrony Financial
-
-
diff --git a/WebContent/index.jsp b/WebContent/index.jsp
index c9e4a6a..bec4e8a 100644
--- a/WebContent/index.jsp
+++ b/WebContent/index.jsp
@@ -122,15 +122,11 @@ Cookie newCookie;
if(usercookies != null){
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
- navsso = c.getValue();
- c.setMaxAge(0);//delete current
- newCookie = new Cookie("ssoNum",navsso); //make new one
- newCookie.setMaxAge(30*60);
- response.addCookie(newCookie);
- break;
+ if(c.getValue().equals("") == false){
+ response.sendRedirect("html/webpages/index.jsp");
+ return;
+ }
}
}
-}
-if(navsso.equals("invalid") == false)//if we did get cookie, redirect to the homepage!
- response.sendRedirect("html/webpages/index.jsp");
+}
%>
diff --git a/WebContent/userLogin.jsp b/WebContent/userLogin.jsp
index 54f84ca..373502d 100644
--- a/WebContent/userLogin.jsp
+++ b/WebContent/userLogin.jsp
@@ -21,6 +21,7 @@ if (result.next()){
session.setAttribute("ssoNum", ssoNum);
userCookie = new Cookie("ssoNum", Integer.toString(ssoNum));
userCookie.setMaxAge(30*60);
+ userCookie.setPath("/");
response.addCookie(userCookie);
stmt.close();
connection.close();
@@ -28,7 +29,7 @@ if (result.next()){
} else {
stmt.close();
connection.close();
- response.sendRedirect("index.jsp");
+ response.sendRedirect("html/webpages/index.jsp");
}
%>
\ No newline at end of file
diff --git a/src/database/AdminQueries.java b/src/database/AdminQueries.java
new file mode 100644
index 0000000..4a7f3a3
--- /dev/null
+++ b/src/database/AdminQueries.java
@@ -0,0 +1,36 @@
+package database;
+
+import java.sql.*;
+
+public class AdminQueries {
+
+ private static String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
+ private static String user = "b372dfe7409692";
+ private static String password = "74f6e317";
+
+ public static boolean isAdmin(int id) throws ClassNotFoundException, SQLException{
+ System.getenv("VCAP_SERVICES");
+ Class.forName("com.mysql.jdbc.Driver");
+ Connection connection = DriverManager.getConnection(database, user, password);
+ Statement stmt = connection.createStatement();
+ ResultSet results = stmt.executeQuery("SELECT * from admin WHERE Admin_ID = " + id);
+ results.next();
+ return true;
+ }
+
+ /**
+ * Checks to see if a pincode is numeric.
+ * @param pincode
+ * @return
+ */
+ public static boolean pincodeInt(String pincode){
+ try{
+ Integer.parseInt(pincode);
+ return true;
+ }
+ catch(NumberFormatException e){
+ return false;
+ }
+ }
+
+}
diff --git a/src/database/DeviceQueries.java b/src/database/DeviceQueries.java
index 86afc5a..248a400 100644
--- a/src/database/DeviceQueries.java
+++ b/src/database/DeviceQueries.java
@@ -27,7 +27,7 @@ public static Device[] getUserDevices(String userID) throws SQLException, ClassN
//iterate result set
while(resultSet.next()){
- devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getInt("NFC_ID"));
+ devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getString("NFC_ID"));
counter++;
}
stmt.close();
@@ -53,7 +53,7 @@ public static Device[] getAllDevices() throws SQLException, ClassNotFoundExcepti
//iterate result set
while(resultSet.next()){
- devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getInt("NFC_ID"));
+ devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getString("NFC_ID"));
counter++;
}
stmt.close();
@@ -79,7 +79,7 @@ public static Device[] getAvailableDevices() throws SQLException, ClassNotFoundE
//iterate result set
while(resultSet.next()){
- devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getInt("NFC_ID"));
+ devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getString("NFC_ID"));
counter++;
}
stmt.close();
@@ -126,7 +126,7 @@ public static void addDevice(Device device) throws SQLException, ClassNotFoundEx
id = results.getInt("Device_ID");
id++;
//tries this statement, otherwise tries again with a new id
- String command = "INSERT INTO devices (Device_ID,Device_Name,Device_Description,MAC_Address,Manufacturer,Hardware,Model,Serial_Num,Status,Added_By,NFC_ID) " + "VALUES (" + id +",\"" + device.getName() + "\",\"" + device.getDesc()+ "\",\"" + device.getMAC() + "\",\"" + device.getManufacturer() + "\",\""+device.getHardware()+ "\",\"" + device.getModel() + "\",\"" + device.getSerial() + "\",\"" + device.getStatus() + "\",30," + device.getNFC() + ");"; //TODO update the Added_By to include cookies
+ String command = "INSERT INTO devices (Device_ID,Device_Name,Device_Description,MAC_Address,Manufacturer,Hardware,Model,Serial_Num,Status,Added_By,NFC_ID) " + "VALUES (" + id +",\"" + device.getName() + "\",\"" + device.getDesc()+ "\",\"" + device.getMAC() + "\",\"" + device.getManufacturer() + "\",\""+device.getHardware()+ "\",\"" + device.getModel() + "\",\"" + device.getSerial() + "\",\"" + device.getStatus() + "\",30,\"" + device.getNFC() + "\");"; //TODO update the Added_By to include cookies
System.out.println(command);
i = stmt.executeUpdate(command);
}
@@ -139,7 +139,7 @@ public static void modifyDevice(Device device) throws ClassNotFoundException, SQ
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
- stmt.executeUpdate("UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = " + device.getNFC() + " WHERE Device_ID = " + device.getID());
+ stmt.executeUpdate("UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = \"" + device.getNFC() + "\" WHERE Device_ID = " + device.getID());
stmt.close();
connection.close();
}
diff --git a/src/entities/Admin.java b/src/entities/Admin.java
index 2ebfd89..a175178 100644
--- a/src/entities/Admin.java
+++ b/src/entities/Admin.java
@@ -6,8 +6,13 @@
*/
public class Admin extends User {
- public Admin(int id, int location, String name, String phone, String email, int icon) {
- super(id, location, name, phone, email, icon);
+ private int password_flag;
+ private int finger_flag;
+
+ public Admin(int id, int location, String name, String phone, String email, int icon, int pass, int finger) {
+ super(id, location, name, phone, email, icon);
+ password_flag = pass;
+ finger_flag = finger;
}
}
diff --git a/src/entities/Device.java b/src/entities/Device.java
index 2111da6..5e3f871 100644
--- a/src/entities/Device.java
+++ b/src/entities/Device.java
@@ -15,9 +15,9 @@ public class Device {
private String Status;
private String MAC;
private String Serial;
- private int NFC;
+ private String NFC;
- public Device(String name, int id, String desc, String hardware, String model, String manufacturer, String available, String mac, String serial, int nfc) {
+ public Device(String name, int id, String desc, String hardware, String model, String manufacturer, String available, String mac, String serial, String nfc) {
Device_Name = name;
Device_ID = id;
Device_Description = desc;
@@ -44,7 +44,7 @@ public String toString(){
sb.append("\"manufacturer\": \"").append(Manu).append("\"").append(comma);
sb.append("\"mac\": \"").append(MAC).append("\"").append(comma);
sb.append("\"serial\": \"").append(Serial).append("\"").append(comma);
- sb.append("\"nfc\": ").append(NFC);
+ sb.append("\"nfc\": \"").append(NFC).append("\"");
sb.append("}");
return sb.toString();
}
@@ -99,7 +99,7 @@ public String getSerial(){
return Serial;
}
- public int getNFC() {
+ public String getNFC() {
return NFC;
}