Skip to content

Commit e2e5335

Browse files
committed
Version 1.1.0
1 parent a9873e0 commit e2e5335

7 files changed

Lines changed: 232 additions & 208 deletions

File tree

src/main/java/AuthenticationModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import java.time.LocalDateTime;
44
import java.time.format.DateTimeFormatter;
55

6+
/** AuthenticationModule.java
7+
* For user & admin login and keeping last-login time
8+
* @author Yash Shinde
9+
* @version 1.1.0
10+
*/
611
public class AuthenticationModule {
712
private static String typequery;
813

src/main/java/BackupManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import java.io.*;
33
import java.sql.*;
44

5+
/** BackupManager.java
6+
* Storing and retrieving user files in embedded database
7+
* max file size limit = 900mb (SQLite blob)
8+
*/
59
public class BackupManager {
610
static final String DB_URL = "jdbc:sqlite:unified.db";
711
static final long MAX_FILE_SIZE = 900 * 1024 * 1024;

src/main/java/DbHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
* Methods for handling backend of database operations
1414
* Creates necessary tables on startup of system
1515
* @author Yash Shinde
16-
*/
16+
* @version 1.1.0
17+
*/
1718

1819
public class DbHandler {
1920
protected static final String DB_URL = "jdbc:sqlite:unified.db"; //Database URL , name : unified.db
2021
private static final String CREATE_USERDATA_TABLE_SQL = "CREATE TABLE IF NOT EXISTS userdata (id INTEGER PRIMARY KEY AUTOINCREMENT ,username TEXT NOT NULL UNIQUE , password TEXT NOT NULL, Last_Login TEXT)";
2122
private static final String CREATE_FILES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS files(id INTEGER PRIMARY KEY AUTOINCREMENT,filename TEXT NOT NULL,filedata BLOB NOT NULL,username TEXT NOT NULL, isEncrypted INTEGER NOT NULL DEFAULT 0)";
22-
private static final String CREATE_KEYS_TABLE_SQL = "CREATE TABLE IF NOT EXISTS keys (keyId INTEGER PRIMARY KEY AUTOINCREMENT,id INTEGER, username TEXT NOT NULL , filename TEXT NOT NULL, key TEXT NOT NULL,IniVec VARBINARY(16) NOT NULL,FOREIGN KEY (id) REFERENCES files(id) ON DELETE CASCADE,FOREIGN KEY (username) REFERENCES userdata(username) ON DELETE CASCADE)";
23+
private static final String CREATE_KEYS_TABLE_SQL = "CREATE TABLE IF NOT EXISTS keys (keyId INTEGER PRIMARY KEY AUTOINCREMENT,id INTEGER, username TEXT NOT NULL , filename TEXT NOT NULL, key TEXT NOT NULL,IniVec TEXT NOT NULL,FOREIGN KEY (id) REFERENCES files(id) ON DELETE CASCADE,FOREIGN KEY (username) REFERENCES userdata(username) ON DELETE CASCADE)";
2324
private static final String CREATE_ADMIN_DATA_TABLE_SQL = "CREATE TABLE IF NOT EXISTS Admindata (id INTEGER PRIMARY KEY AUTOINCREMENT ,AdminName TEXT NOT NULL UNIQUE , password TEXT NOT NULL, Last_Login TEXT)";
25+
2426
static void setupDatabase() {
25-
27+
//Initializes all tables and adds default admin if no admins exist
2628
try (Connection conn = DriverManager.getConnection(DB_URL);
2729
Statement stmt = conn.createStatement()) {
2830
stmt.execute("PRAGMA foreign_keys = ON"); //Foreign key support
@@ -35,7 +37,8 @@ static void setupDatabase() {
3537
JOptionPane.showMessageDialog(null,"Error setting up database: \n" + e.getMessage() + "\n");
3638
}
3739
}
38-
static void AdminInit(){ //Initializes default Admin
40+
static void AdminInit(){
41+
//Initializes default Admin
3942
String initAdm = UserManager.hashPassword("Admin");
4043
String checkAdminSQL = "SELECT COUNT(*) FROM Admindata";
4144
try (Connection conn = DriverManager.getConnection(DB_URL); PreparedStatement pstmtCheck = conn.prepareStatement(checkAdminSQL)) {

src/main/java/GUI.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.net.URISyntaxException;
1010

1111
/**Project : Secure Storage Manager
12-
* @version 1.0.0
12+
* @version 1.1.0
1313
* This is the main class to the project
1414
* @author Yash Shinde
1515
*/
@@ -143,22 +143,23 @@ public void mouseExited(MouseEvent e) {
143143
login.setVisible(true);
144144

145145
help.addActionListener(e ->{JOptionPane.showMessageDialog(null,"Secure Storage Manager release 1.0.0 \n\n"
146-
+"AES 256 : Symmetric encryption of files with any extension type , files can be stored on embedded database or local directory based on size ,\ngenerates secure random key and initialization vector.\n\n"
146+
+"NEW! : Custom AES Decryption CBC+ECB\n\n"+"AES 256 : Symmetric encryption of files with any extension type , files can be stored on embedded database or local directory based on size ,\ngenerates secure random key and initialization vector.\n\n"
147147
+"SHA File Checksum : Generates SHA256/512 hash for a file.\n\n"+
148148
"File Database Backup : Encodes file data and stores directly on embedded database without encryption.\n\n"
149149
+"Admin login : For directly manipulating database with predefined tools (Default ID,Password : (Admin,Admin) , can be updated).\n\n"
150150
+"User login : Credentials are hashed and stored securely.\n\n");});
151151

152152
/*User login , default Admin is created at startup
153-
*creadentials for Admin can be changed in program aswell as in source (DbHandler.java)
153+
*credentials for Admin can be changed in program as well as in source (DbHandler.java)
154154
* Default Admin login : username = Admin , password = Admin
155155
*/
156156
Log.addActionListener(e -> {AuthenticationModule.loginUser(0); });
157157
Admlog.addActionListener(e -> {AuthenticationModule.loginUser(1);});
158158
Reg.addActionListener(e -> UserManager.registerUser(userField,passwdField));
159159
}
160160

161-
private JButton getButton() { //Custom JButton for link to source
161+
private JButton getButton() {
162+
//Custom JButton for link to source
162163
JButton yp = new JButton();
163164
yp.setBounds(0, 0, 570,(int)screenSize.getHeight());
164165
yp.setOpaque(false);

src/main/java/MainFrame.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/** MainFrame.java
2424
* User GUI with all cryptographic,file management functionalities
2525
* @author Yash Shinde
26+
* @version 1.1.0
2627
*/
2728

2829
public class MainFrame {
@@ -80,6 +81,7 @@ public MainFrame(){
8081

8182
JButton enc = new JButton("AES File Encryption");
8283
JButton dec = new JButton("AES File Decryption");
84+
JButton custDec = new JButton("Custom AES Decryption");
8385
JButton vf = new JButton("View Files");
8486
JButton rm_file = new JButton("Remove Files");
8587
JButton SHA2 = new JButton("SHA-256 File Checksum");
@@ -92,13 +94,14 @@ public MainFrame(){
9294
fileButtonPanel.add(vk);
9395
fileButtonPanel.add(enc);
9496
fileButtonPanel.add(dec);
97+
fileButtonPanel.add(custDec);
9598
fileButtonPanel.add(rm_file);
9699
fileButtonPanel.add(reset);
97100
fileButtonPanel.add(saveFileButton);
98101
fileButtonPanel.add(retrieveFileButton);
99102
for (Component component : fileButtonPanel.getComponents()) {
100103
component.setBackground(Color.GRAY);
101-
component.setPreferredSize(new Dimension(200,55));
104+
component.setPreferredSize(new Dimension(200,50));
102105
component.setFocusable(false);
103106
}
104107

@@ -115,6 +118,9 @@ public MainFrame(){
115118

116119
Logout.addActionListener(e-> { //logs out to login GUI
117120
feedbackArea.setText(" ");
121+
mode=0;
122+
feedbackArea.setBackground(null);
123+
feedbackArea.setForeground(null);
118124
mainframe.dispose();
119125
GUI.login.setVisible(true);
120126
});
@@ -138,7 +144,7 @@ else if(choice==1){
138144
//Fetches keys for user
139145
vk.addActionListener(e -> DbHandler.executeSQLQuery(feedbackArea,"SELECT* FROM keys WHERE username="+"'"+GUI.loggedInUser+"'",tableModel));
140146

141-
enc.addActionListener(e -> SecurityTools.encryptFileToDatabase()); //AES Encryption
147+
enc.addActionListener(e -> SecurityTools.encryptFileToDatabase(null)); //AES Encryption
142148
dec.addActionListener(e -> SecurityTools.decryptFile()); //AES Decryption
143149

144150
//Fetches files for user
@@ -249,6 +255,7 @@ else if(choice==1){
249255
resultTable.setFillsViewportHeight(true);
250256
tableScrollPane.getViewport().setBackground(Color.WHITE);
251257
});
258+
custDec.addActionListener(e-> SecurityTools.customDecryption());
252259

253260
}
254261

0 commit comments

Comments
 (0)