- Timestamp:
- 04/05/19 10:25:31 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/auth/Actions.java
r1280 r1283 100 100 if (!DisplayController.isMailMode()) { 101 101 Mail.clear(); 102 Authenticator .getInstance().loadMailDatabase();102 AuthenticatorBrowser.getInstance().loadMailDatabase(); 103 103 } 104 104 DisplayController.ToggleMailMode(); … … 172 172 createAccount(userData); 173 173 login(userData); 174 Authenticator .Authenticated = true;174 AuthenticatorBrowser.Authenticated = true; 175 175 } else { 176 176 MessageBay.errorMessage(Constants.ERROR_INSUFFICIENT_INFORMATION_PROVIDED); … … 189 189 if (userdata.isPresent()) { 190 190 login(userdata.get()); 191 Authenticator .Authenticated = true;191 AuthenticatorBrowser.Authenticated = true; 192 192 } else { 193 193 MessageBay.errorMessage(Constants.ERROR_INSUFFICIENT_INFORMATION_PROVIDED); … … 211 211 final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems(); 212 212 213 if (!Authenticator .Authenticated) {213 if (!AuthenticatorBrowser.Authenticated) { 214 214 MessageBay.errorMessage(Constants.ERROR_MUST_BE_LOGGED_IN); 215 215 } else { … … 230 230 231 231 public static void AuthGotoAccountManagement() { 232 if (Authenticator .Authenticated) {232 if (AuthenticatorBrowser.Authenticated) { 233 233 DisplayController.setCurrentFrame(FrameIO.LoadFrame(Constants.FRAME_MULTIUSER1), false); 234 234 } else { … … 284 284 Collection<Text> textItems = currentFrame.getTextItems(); 285 285 286 if (!Authenticator .Authenticated) {286 if (!AuthenticatorBrowser.Authenticated) { 287 287 MessageBay.errorMessage(Constants.ERROR_MUST_BE_LOGGED_IN); 288 288 return; … … 369 369 rand.nextBytes(keyBytes); 370 370 SecretKey key = new SecretKeySpec(keyBytes, SymmetricAlgorithm); 371 Authenticator .getInstance().putKey(username, password, key);371 AuthenticatorBrowser.getInstance().putKey(username, password, key); 372 372 String personalKey = Base64.getEncoder().encodeToString(key.getEncoded()); 373 373 // Public and private keys … … 401 401 Map<String, Consumer<Frame>> notifiers = new HashMap<String, Consumer<Frame>>(); 402 402 notifiers.put(Constants.SETTINGS_AUTH, frame -> { 403 Authenticator .CREDENTIALS_FRAME = frame.getNumber();403 AuthenticatorBrowser.CREDENTIALS_FRAME = frame.getNumber(); 404 404 Collection<Text> textItems = frame.getTextItems(); 405 405 for (Text t: textItems) { … … 424 424 f.getAllItems().stream().forEach(item -> item.setOwner(username)); 425 425 f.setChanged(true); 426 if (f.getNumber() != Authenticator .CREDENTIALS_FRAME) {426 if (f.getNumber() != AuthenticatorBrowser.CREDENTIALS_FRAME) { 427 427 f.setEncryptionLabel("Profile"); 428 428 } … … 441 441 } 442 442 443 if (Authenticator .CREDENTIALS_FRAME == -1) {443 if (AuthenticatorBrowser.CREDENTIALS_FRAME == -1) { 444 444 System.err.println("authActions::Unable to establish credentials frame for new profile frame. Account creation failed."); 445 445 return; … … 456 456 credentialsFile.createNewFile(); 457 457 FileWriter out = new FileWriter(credentialsFile); 458 out.write(Authenticator .CREDENTIALS_FRAME + ".exp");458 out.write(AuthenticatorBrowser.CREDENTIALS_FRAME + ".exp"); 459 459 out.flush(); 460 460 out.close(); 461 461 // migrate credentials frame 462 Frame credentialsFrame = FrameIO.LoadFrame(username + Authenticator .CREDENTIALS_FRAME);462 Frame credentialsFrame = FrameIO.LoadFrame(username + AuthenticatorBrowser.CREDENTIALS_FRAME); 463 463 Path destinationDirectory = Paths.get(credentialsDir.getAbsolutePath()); 464 Path destinationFile = destinationDirectory.resolve(Authenticator .CREDENTIALS_FRAME + ExpReader.EXTENTION);464 Path destinationFile = destinationDirectory.resolve(AuthenticatorBrowser.CREDENTIALS_FRAME + ExpReader.EXTENTION); 465 465 FrameIO.migrateFrame(credentialsFrame, destinationFile); 466 466 … … 498 498 499 499 try { 500 personalKey = Authenticator .getInstance().getSecretKey(username, password);500 personalKey = AuthenticatorBrowser.getInstance().getSecretKey(username, password); 501 501 } catch (Exception e) { 502 502 // leave personalKey null … … 523 523 524 524 Frame oneFrame = null; 525 if (!username.equals(Authenticator .ADMINACCOUNT)) {525 if (!username.equals(AuthenticatorBrowser.ADMINACCOUNT)) { 526 526 // Load in and cache the profile frame using the personal key fetched from keystore. 527 527 // Reset the personal key once finished so that setting parsing can correctly set it. … … 534 534 for (int i = 1; i <= FrameIO.getLastNumber(username); i++) { 535 535 Frame f = FrameIO.LoadFrame(oneFrame.getFramesetName() + i); 536 if (f .getData() != null && f.getData().contains("MultiuserCredentials")) {537 Authenticator .CREDENTIALS_FRAME = f.getNumber();536 if (f != null && f.getData() != null && f.getData().contains("MultiuserCredentials")) { 537 AuthenticatorBrowser.CREDENTIALS_FRAME = f.getNumber(); 538 538 } 539 539 } … … 549 549 // Check mail 550 550 MailBay.clear(); 551 Authenticator .getInstance().loadMailDatabase();551 AuthenticatorBrowser.getInstance().loadMailDatabase(); 552 552 Text keyItem = org.expeditee.settings.identity.secrets.KeyList.PrivateKey.get(); 553 553 if (keyItem.getData() != null) { … … 555 555 byte[] keyBytes = Base64.getDecoder().decode(keyEncoded); 556 556 PrivateKey key = KeyFactory.getInstance(AsymmetricAlgorithm).generatePrivate(new PKCS8EncodedKeySpec(keyBytes)); 557 List<MailEntry> mailForLoggingInUser = Mail.getEntries(UserSettings.UserName.get(), key); 557 List<MailEntry> mailForLoggingInUser = Mail.getEntries(UserSettings.UserName.get(), key); 558 558 for (MailEntry mail: mailForLoggingInUser) { 559 559 MailBay.addMessage(mail.timestamp, mail.message, mail.message2, mail.options); 560 560 } 561 561 } 562 Path deadDropPath = Paths.get(FrameIO.DEAD_DROPS_PATH); 563 for (File connectionDir: deadDropPath.toFile().listFiles()) { 564 if (connectionDir.isDirectory()) { 565 Path deaddropforcontactPath = Paths.get(connectionDir.getAbsolutePath()); 566 AuthenticatorBrowser.getInstance().updateLastReadMailTime(deaddropforcontactPath); 567 } 568 } 569 562 570 } else { 563 UserSettings.UserName.set(Authenticator .ADMINACCOUNT);571 UserSettings.UserName.set(AuthenticatorBrowser.ADMINACCOUNT); 564 572 oneFrame = FrameIO.LoadFrame("multiuser1"); 565 573 } … … 606 614 String colleagueOne = userData.get(AuthenticationTag.ColleagueOne); 607 615 String colleagueTwo = userData.get(AuthenticationTag.ColleagueTwo); 608 PublicKey colleagueOneKey = Authenticator .getInstance().getPublicKey(colleagueOne);609 PublicKey colleagueTwoKey = Authenticator .getInstance().getPublicKey(colleagueTwo);616 PublicKey colleagueOneKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueOne); 617 PublicKey colleagueTwoKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueTwo); 610 618 if (colleagueOneKey == null) { 611 619 MessageBay.errorMessage("Unable to get public key for colleague: " + colleagueOne); … … 626 634 mail = new MailEntry(time, sender, colleagueTwo, topic, message, arguments); 627 635 Mail.sendMail(mail, colleagueTwo); 628 Authenticator .getInstance().markRequestedColleagues(UserSettings.UserName.get());636 AuthenticatorBrowser.getInstance().markRequestedColleagues(UserSettings.UserName.get()); 629 637 return true; 630 638 } … … 661 669 final String newpassword = userdata.get(AuthenticationTag.NewPassword); 662 670 663 final SecretKey key = Authenticator .getInstance().getSecretKey(username, password);671 final SecretKey key = AuthenticatorBrowser.getInstance().getSecretKey(username, password); 664 672 if (key == null) { 665 673 MessageBay.errorMessage("The username + existing password combination was incorrect."); 666 674 } else { 667 Authenticator .getInstance().putKey(username, newpassword, key);675 AuthenticatorBrowser.getInstance().putKey(username, newpassword, key); 668 676 MessageBay.displayMessage("Password changed successfully."); 669 677 } -
trunk/src/org/expeditee/auth/Mail.java
r1277 r1283 2 2 3 3 import java.io.File; 4 import java.io.FileNotFoundException; 4 5 import java.io.IOException; 5 6 import java.nio.file.Path; … … 17 18 import java.sql.SQLException; 18 19 import java.sql.Statement; 20 import java.text.ParseException; 21 import java.text.SimpleDateFormat; 19 22 import java.util.ArrayList; 20 23 import java.util.Arrays; 21 24 import java.util.Base64; 25 import java.util.Date; 22 26 import java.util.HashMap; 23 27 import java.util.List; 24 28 import java.util.Map; 29 import java.util.Scanner; 25 30 26 31 import javax.crypto.BadPaddingException; … … 78 83 PublicKey publicKey = null; 79 84 try { 80 publicKey = Authenticator .getInstance().getPublicKey(colleagueName);85 publicKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueName); 81 86 } catch (InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException | CertificateException 82 87 | ClassNotFoundException | IOException | SQLException e) { … … 182 187 } 183 188 184 //String arguments = new String(c.doFinal(Base64.getDecoder().decode(mail.args))); 185 filtered.add(new MailEntry(mail.timestamp, sender, receiverDecrypted, message, message2, options)); 189 Path lastAccessedFile = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(sender).resolve(name + ".last-accessed"); 190 SimpleDateFormat format = new SimpleDateFormat("ddMMMyyyy[HH:mm]"); 191 MailEntry mailEntry = new MailEntry(mail.timestamp, sender, receiverDecrypted, message, message2, options); 192 try (Scanner in = new Scanner(lastAccessedFile.toFile())) { 193 Date lastAccessedTimestamp = format.parse(in.nextLine()); 194 Date mailTimestamp = format.parse(mail.timestamp); 195 if (mailTimestamp.after(lastAccessedTimestamp)) { 196 filtered.add(mailEntry); 197 } 198 } catch (FileNotFoundException e) { 199 // It may not have been created yet, then err on the safe side and add it in. 200 filtered.add(mailEntry); 201 } catch (ParseException e) { 202 // If we fail to parse, then err on the safe side and add it in. 203 filtered.add(mailEntry); 204 } 205 186 206 } 187 207 } -
trunk/src/org/expeditee/gui/FrameCreator.java
r1280 r1283 115 115 int lastNumber = FrameIO.getLastNumber(framesetName); 116 116 for (int i = 1; i <= lastNumber; i++) { 117 Frame frame = FrameIO.LoadFrame(framesetName + i, path.toAbsolutePath().toString() );117 Frame frame = FrameIO.LoadFrame(framesetName + i, path.toAbsolutePath().toString() + File.separator); 118 118 this.framesCreated.add(frame); 119 119 } … … 147 147 resetGlobals(toUse); 148 148 _firstFrame = toUse; 149 150 path.toAbsolutePath().resolve(framesetName);151 149 } catch (InvalidFramesetNameException e) { 152 150 e.printStackTrace(); -
trunk/src/org/expeditee/gui/FrameIO.java
r1280 r1283 50 50 import org.expeditee.agents.ExistingFramesetException; 51 51 import org.expeditee.agents.InvalidFramesetNameException; 52 import org.expeditee.auth.Authenticator ;52 import org.expeditee.auth.AuthenticatorBrowser; 53 53 import org.expeditee.auth.EncryptedExpReader; 54 54 import org.expeditee.auth.EncryptedExpWriter; … … 375 375 List<String> directoriesToSearch = FolderSettings.FrameDirs.getAbsoluteDirs(); 376 376 377 if (Authenticator .Authenticated) {377 if (AuthenticatorBrowser.Authenticated) { 378 378 // if we are running Expeditee Authenticated, consult user profile as location for framesets first 379 379 String profilePath = FrameIO.PROFILE_PATH + UserSettings.UserName.get() + File.separator; … … 1102 1102 // if its a new frame or an existing Exp frame... 1103 1103 if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) { 1104 if (toSave.getNumber() != Authenticator .CREDENTIALS_FRAME &&1104 if (toSave.getNumber() != AuthenticatorBrowser.CREDENTIALS_FRAME && 1105 1105 toSave.getEncryptionLabel() != null) { 1106 1106 writer = new EncryptedExpWriter(toSave.getEncryptionLabel());
Note:
See TracChangeset
for help on using the changeset viewer.