- Timestamp:
- 03/25/19 14:33:31 (5 years ago)
- Location:
- trunk/src/org
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/ApolloSystem.java
r1244 r1270 156 156 if (profile == null) { 157 157 try { 158 profile = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null );158 profile = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null, null); 159 159 } catch (Exception e) { 160 160 e.printStackTrace(); -
trunk/src/org/expeditee/actions/Misc.java
r1258 r1270 1334 1334 homeFrame.removeAllItems(homeFrame.getItems()); 1335 1335 homeFrame.addText(0, 0, "title", null); 1336 FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame, null );1336 FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame, null, null); 1337 1337 } 1338 1338 -
trunk/src/org/expeditee/auth/Actions.java
r1263 r1270 32 32 import java.util.Optional; 33 33 import java.util.Random; 34 import java.util.function.Consumer; 34 35 import java.util.stream.Collectors; 35 36 … … 67 68 68 69 public class Actions implements CryptographyConstants { 69 70 71 //Debug Functions 70 72 public static void SendTestMessage(String colleagueName) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException, KeyStoreException, CertificateException, ClassNotFoundException, IOException, SQLException { 71 73 String time = org.expeditee.stats.Formatter.getDateTime(); … … 79 81 Path outbox = Paths.get(FrameIO.PROFILE_PATH).resolve(sender).resolve(sender + "-credentials"); 80 82 Mail.sendMail(mail, publicKey, outbox); 83 } 84 private static String userbackup = "authadmin"; 85 public static void ToggleAuth() { 86 String backup = UserSettings.UserName.get(); 87 UserSettings.UserName.set(userbackup); 88 userbackup = backup; 81 89 } 82 90 … … 394 402 initialSettings.put("org.expeditee.gui.folders.FolderSettings.AudioDirs", FolderSettings.AudioDirs); 395 403 404 // Record the credentials frame number 405 Map<String, Consumer<Frame>> notifiers = new HashMap<String, Consumer<Frame>>(); 406 notifiers.put(Constants.SETTINGS_AUTH, frame -> { 407 Authenticator.CREDENTIALS_FRAME = frame.getNumber(); 408 Collection<Text> textItems = frame.getTextItems(); 409 for (Text t: textItems) { 410 if (t.getText().equals("Secrets")) { 411 t.setPermission(new PermissionPair(UserAppliedPermission.followLinks, UserAppliedPermission.denied)); 412 break; 413 } 414 } 415 }); 416 396 417 // Create users profile 397 Frame profile = FrameIO.CreateNewProfile(username, initialSettings );418 Frame profile = FrameIO.CreateNewProfile(username, initialSettings, notifiers); 398 419 int lastNumber = FrameIO.getLastNumber(profile.getFramesetName()); 399 420 for (int i = 1; i <= lastNumber; i++) { … … 407 428 f.getAllItems().stream().forEach(item -> item.setOwner(username)); 408 429 f.setChanged(true); 409 f.setEncryptionLabel("Profile"); 430 if (f.getNumber() != Authenticator.CREDENTIALS_FRAME) { 431 f.setEncryptionLabel("Profile"); 432 } 410 433 Collection<Item> secretsLink = getByContent(f, "Secrets"); 411 434 Collection<Item> publicKeyItem = getByContent(f, "PublicKey"); 412 435 if (!secretsLink.isEmpty() && !publicKeyItem.isEmpty()) { 413 436 //Then we are on credentials frame 414 secretsLink.forEach(text -> text.setPermission(new PermissionPair(UserAppliedPermission.full, UserAppliedPermission.none)));415 437 f.addToData("MultiuserCredentials"); 416 438 } … … 421 443 FrameIO.SaveFrame(f); 422 444 KeyList.PersonalKey.setSetting(backupPersonalKey); 445 } 446 447 if (Authenticator.CREDENTIALS_FRAME == -1) { 448 System.err.println("authActions::Unable to establish credentials frame for new profile frame. Account creation failed."); 449 return; 423 450 } 424 451 … … 436 463 out.flush(); 437 464 out.close(); 465 // migrate credentials frame 466 Frame credentialsFrame = FrameIO.LoadFrame(username + Authenticator.CREDENTIALS_FRAME); 467 FrameIO.migrateFrame(credentialsFrame, Paths.get(credentialsDir.getAbsolutePath()).resolve(Authenticator.CREDENTIALS_FRAME + ".exp")); 438 468 // outbox 439 469 Connection c = DriverManager.getConnection("jdbc:sqlite:" + credentialsDir.getAbsolutePath() + File.separator + "expmail.db"); -
trunk/src/org/expeditee/auth/Authenticator.java
r1267 r1270 64 64 65 65 // The frame number of the frame containing the current authenticated users public key. 66 public static int CREDENTIALS_FRAME = 13;66 public static int CREDENTIALS_FRAME = -1; 67 67 public static final String ADMINACCOUNT = "authadmin"; 68 68 -
trunk/src/org/expeditee/auth/tags/Constants.java
r1243 r1270 19 19 public static final String SETTINGS_USER_SETTINGS_PROFILE_NAME = "settings.UserSettings.ProfileName"; 20 20 public static final String SETTINGS_USER_SETTINGS_USER_NAME = "settings.UserSettings.UserName"; 21 public static final String SETTINGS_AUTH = "settings.identity"; 21 22 public static final String SETTINGS_AUTH_EMAIL = "settings.identity.Email"; 22 23 public static final String SETTINGS_AUTH_PUBLIC_KEY = "settings.identity.PublicKey"; -
trunk/src/org/expeditee/gui/Browser.java
r1264 r1270 553 553 if (profile == null) { 554 554 try { 555 profile = FrameIO.CreateNewProfile(userName, null );555 profile = FrameIO.CreateNewProfile(userName, null, null); 556 556 } catch (Exception e) { 557 557 // TODO tell the user that there was a problem creating the -
trunk/src/org/expeditee/gui/FrameIO.java
r1257 r1270 43 43 import java.util.List; 44 44 import java.util.Map; 45 import java.util.function.Consumer; 45 46 import java.util.stream.Collectors; 46 47 … … 1349 1350 } 1350 1351 1351 public static Frame CreateNewProfile(String username, Map<String, Setting> initialSettings ) throws InvalidFramesetNameException, ExistingFramesetException {1352 public static Frame CreateNewProfile(String username, Map<String, Setting> initialSettings, Map<String, Consumer<Frame>> toNotifyOnSet) throws InvalidFramesetNameException, ExistingFramesetException { 1352 1353 Frame profile = CreateFrameset(username, PROFILE_PATH, true); 1353 FrameUtils.CreateDefaultProfile(username, profile, initialSettings );1354 FrameUtils.CreateDefaultProfile(username, profile, initialSettings, toNotifyOnSet); 1354 1355 return profile; 1355 1356 } … … 1924 1925 } 1925 1926 1926 public static Path setupPersonalResources(String username) 1927 { 1927 public static Path setupPersonalResources(String username) { 1928 1928 Path personalResources = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username); 1929 1929 personalResources.toFile().mkdir(); … … 1944 1944 1945 1945 return personalResources; 1946 } 1947 1948 public static void migrateFrame(Frame toMigrate, Path destinationDirectory) { 1949 Path source = Paths.get(toMigrate.getFramePathReal()); 1950 String destination = source.relativize(destinationDirectory).toString().substring(3).replace(File.separator, "/"); 1951 try { 1952 copyFileTree(source, destinationDirectory); 1953 } catch (IOException e) { 1954 System.err.println("FrameIO::migrateFrame: failed to migrate from to new location. Message: " + e.getMessage()); 1955 return; 1956 } 1957 try { 1958 FileWriter out = new FileWriter(source.toFile()); 1959 out.write("REDIRECT:" + destination); 1960 out.flush(); 1961 out.close(); 1962 } catch (IOException e) { 1963 System.err.println("FrameIO::migrateFrame: failed to update file [" + source + "] to redirect to [" + destination + "] following migration. Message: " + e.getMessage()); 1964 } 1946 1965 } 1947 1966 -
trunk/src/org/expeditee/gui/FrameUtils.java
r1244 r1270 41 41 import java.util.List; 42 42 import java.util.Map; 43 import java.util.function.Consumer; 43 44 import java.util.jar.JarEntry; 44 45 import java.util.jar.JarFile; … … 1514 1515 1515 1516 public static void CreateDefaultProfile(String profileFor, Frame profile) { 1516 CreateDefaultProfile(profileFor, profile, null );1517 CreateDefaultProfile(profileFor, profile, null, null); 1517 1518 } 1518 1519 … … 1525 1526 */ 1526 1527 public static void CreateDefaultProfile(String profileFor, Frame profile, 1527 Map<String, Setting> specifiedSettings ) {1528 Map<String, Setting> specifiedSettings, Map<String, Consumer<Frame>> notifyWhenGenerated) { 1528 1529 // If this is already the default profile then nothing (other than setting 1529 1530 // title) needs to be done. … … 1539 1540 try { 1540 1541 // If we do not have a default to copy, create one. 1541 defaultFrame = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null );1542 defaultFrame = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null, null); 1542 1543 } catch (InvalidFramesetNameException invalidNameEx) { 1543 1544 MessageBay.errorMessage("Failed to create default profile named: " … … 1608 1609 } 1609 1610 } 1611 if (notifyWhenGenerated != null && notifyWhenGenerated.containsKey(category)) { 1612 notifyWhenGenerated.get(category).accept(profile); 1613 } 1610 1614 FrameIO.SaveFrame(profile); 1611 1615 } … … 1714 1718 t.setColor(Colour.GREY); 1715 1719 Settings.generateSettingsTree(t); 1720 System.out.println("@Settings: Default settings generation complete."); 1716 1721 1717 1722 FrameIO.SaveFrame(profile);
Note:
See TracChangeset
for help on using the changeset viewer.