Ignore:
Timestamp:
05/17/19 14:37:12 (5 years ago)
Author:
bln4
Message:

It is now possible to complete the process of recovering access to a Expeditee account. Further work, in the form of frames in the authentication frameset, are to follow.
A refactoring/tidy up has also been completed.

Location:
trunk/src/org/expeditee/auth/mail
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/auth/mail/Mail.java

    r1362 r1363  
    1 package org.expeditee.auth;
     1package org.expeditee.auth.mail;
    22
    33import java.io.File;
     
    3636import javax.crypto.spec.SecretKeySpec;
    3737
    38 import org.expeditee.auth.gui.MailBay;
     38import org.expeditee.auth.AuthenticatorBrowser;
     39import org.expeditee.auth.mail.gui.MailBay;
     40import org.expeditee.encryption.Actions;
    3941import org.expeditee.gui.FrameIO;
    4042import org.expeditee.settings.UserSettings;
     
    5860        public static void sendOneOffMail(MailEntry mail, String colleagueName, byte[] key) {
    5961                // Ensure dead drop area is set up.
    60                 Path databaseFileDirPath = ensureDeadDrops(colleagueName);
     62                Path databaseFileDirPath = ensureDeadDrops(colleagueName, mail.sender);
    6163               
    6264                // Ensure the database file exists.
     
    136138        }
    137139       
     140        private static Path ensureDeadDrops(String colleagueName, String sender) {
     141                String me = sender.toLowerCase();
     142                String them = colleagueName.toLowerCase();
     143                Path parent = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + sender).resolve("deaddrops");
     144                Path databaseFileDirPath = parent.resolve(me + "+" + them);
     145                if (!databaseFileDirPath.toFile().exists()) {
     146                        databaseFileDirPath = parent.resolve(them + "+" + me);
     147                }
     148                return databaseFileDirPath;
     149        }
     150       
    138151        private static void sendMail(MailEntry mail, PublicKey key, Path databaseFile) {
    139152                try {
     
    209222                statement.close();
    210223                c.close();
     224                System.err.println("Message written to database: " + databaseFile.toString());
    211225        }
    212226               
     
    235249                sb.append("Read one-off secure message." + sep);
    236250                sb.append(mail.timestamp + sep);
    237                 sb.append(mail.sender + sep);
     251                sb.append(mail.sender.substring(1) + sep);
    238252                sb.append(mail.receiver + sep);
    239253                sb.append(mail.message + sep);
     
    368382                }
    369383        }
     384
     385        public static void decryptOneOffSecureMessage(SecretKey key, List<String> data) {
     386                byte[] topicBytes = Base64.getDecoder().decode(data.get(3));
     387                String topic = new String(org.expeditee.encryption.Actions.DecryptSymmetric(topicBytes, key));
     388                byte[] messageBytes = Base64.getDecoder().decode(data.get(4));
     389                String message = new String(org.expeditee.encryption.Actions.DecryptSymmetric(messageBytes, key));
     390                Map<String, String> options = new HashMap<String, String>();
     391                for (int i = 5; i < data.size(); i+=2) {
     392                        byte[] optionKeyBytes = Base64.getDecoder().decode(data.get(i));
     393                        String k = new String(org.expeditee.encryption.Actions.DecryptSymmetric(optionKeyBytes, key));
     394                        byte[] optionValueBytes = Base64.getDecoder().decode(data.get(i + 1));
     395                        String v = new String(org.expeditee.encryption.Actions.DecryptSymmetric(optionValueBytes, key));
     396                        options.put(k, v);
     397                }
     398                MailBay.addMessage(data.get(0), topic, message, options);
     399        }
    370400}
Note: See TracChangeset for help on using the changeset viewer.