Changeset 1478 for trunk


Ignore:
Timestamp:
12/03/19 16:30:10 (4 years ago)
Author:
bnemhaus
Message:

Introducing java property 'expeditee.demo-mode', when set to true. With it enabled, any expeditee mail sent will also go to the recipient if they are on the same computer.

Location:
trunk/src/org/expeditee/auth
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/auth/account/Authenticate.java

    r1454 r1478  
    3434import org.expeditee.gui.FrameUtils;
    3535import org.expeditee.gui.MessageBay;
     36import org.expeditee.gui.management.ResourceManager;
    3637import org.expeditee.items.Item;
    3738import org.expeditee.items.Text;
     
    102103                        //Settings.parseSettings(settingsLink);
    103104                        FrameUtils.ParseProfile(oneFrame);
     105                        ResourceManager.invalidateAllResourceDirectories();
    104106                       
    105107                        // At this point we at least login, but maybe with problems.
  • trunk/src/org/expeditee/auth/mail/Mail.java

    r1389 r1478  
    3838import org.expeditee.auth.AuthenticatorBrowser;
    3939import org.expeditee.auth.mail.gui.MailBay;
    40 import org.expeditee.encryption.Actions;
    4140import org.expeditee.encryption.CryptographyConstants;
    4241import org.expeditee.gui.FrameIO;
     
    7069                // Send message
    7170                sendMail(mail, secretKey, databaseFilePath);
     71               
     72                // Do it all again if demo mode is on (ensures sync without having to move db files)
     73                if (Boolean.getBoolean("expeditee.demo-mode")) {
     74                        databaseFileDirPath = ensureDeadDropsDemoMode(colleagueName);
     75                        databaseFilePath = ensureDatabaseFile(colleagueName, databaseFileDirPath);                     
     76                        sendMail(mail, secretKey, databaseFilePath);
     77                }
    7278        }
    7379       
     
    98104                // Send message
    99105                sendMail(mail, publicKey, databaseFilePath);
     106               
     107                // Do it all again if demo mode is on (ensures sync without having to move db files)
     108                if (Boolean.getBoolean("expeditee.demo-mode")) {
     109                        databaseFileDirPath = ensureDeadDropsDemoMode(colleagueName);
     110                        databaseFilePath = ensureDatabaseFile(colleagueName, databaseFileDirPath);
     111                        try {
     112                                publicKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueName);
     113                        } catch (InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException | CertificateException
     114                                        | ClassNotFoundException | IOException | SQLException e) {
     115                                System.err.println("Error while sending message.  Unable to obtain public key for colleague " + 
     116                                        colleagueName + ".  Exception message: " + e.getMessage());
     117                                return;
     118                        }
     119                        if (publicKey == null) {
     120                                System.err.println("(Demo mode) Error while sending message.  Unable to obtain public key for colleague.  Have you exchanged contact details?");
     121                                return;
     122                        }
     123                       
     124                        sendMail(mail, publicKey, databaseFilePath);
     125                }
    100126        }
    101127
     
    138164        }
    139165       
     166        private static Path ensureDeadDropsDemoMode(String colleagueName) {
     167                String me = UserSettings.UserName.get().toLowerCase();
     168                String them = colleagueName.toLowerCase();
     169                String demoModeDeadDropsPath = FrameIO.DEAD_DROPS_PATH.replace(me, them);
     170                Path databaseFileDirPath = Paths.get(demoModeDeadDropsPath).resolve(me + "+" + them);
     171                if (!databaseFileDirPath.toFile().exists()) {
     172                        databaseFileDirPath = Paths.get(demoModeDeadDropsPath).resolve(them + "+" + me);
     173                }
     174                return databaseFileDirPath;
     175        }
     176       
    140177        private static Path ensureDeadDrops(String colleagueName, String sender) {
    141178                String me = sender.toLowerCase();
Note: See TracChangeset for help on using the changeset viewer.