Ignore:
Timestamp:
01/29/20 13:20:24 (4 years ago)
Author:
bnemhaus
Message:

Revised implementation of authenticated Expeditee mail. Motivated by bugs relating to messages not being marked as read and incorrect counting of new messages for users, the Expeditee mail system has been rewritten. The new code not only does not exhibit the previous bugs but is also better engineered. Whilst the MailBay is static (which is in line with the MessageBay), the Mail class is no longer static and must be initialised for each user as they log in.

File:
1 edited

Legend:

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

    r1500 r1504  
    1313import java.util.Base64;
    1414import java.util.Collection;
     15import java.util.Date;
    1516import java.util.HashMap;
    1617import java.util.Iterator;
     
    3334import org.expeditee.auth.mail.Mail;
    3435import org.expeditee.auth.mail.Mail.MailEntry;
     36import org.expeditee.auth.mail.gui.MailBay;
    3537import org.expeditee.auth.tags.AuthenticationTag;
    3638import org.expeditee.encryption.CryptographyConstants;
     
    4446import org.expeditee.settings.identity.passwordrecovery.Colleagues;
    4547import org.expeditee.settings.identity.secrets.KeyList;
    46 import org.expeditee.stats.Formatter;
    4748
    4849import com.codahale.shamir.Scheme;
     
    113114               
    114115                // Get colleagues to distribute messages too.
    115                 String[] colleagues = getPasswordColleaguesFromUsername(username);
     116                String[] trustedUsers = getPasswordColleaguesFromUsername(username);
    116117                //      Send secure message to colleague one
    117                 String colleagueOne = colleagues[0];
    118                 String time = Formatter.getDateTime();
     118                String trustedUserOne = trustedUsers[0];
     119                String time = Mail.FORMAT.format(new Date());
    119120                String topic = "Password Recovery for " + username;
    120121                String message = "Your colleague " + username + " would like you to help them recover access to their account.";
    121122                Map<String, String> options = new HashMap<String, String>();
    122123                options.put("Provide assistance", "AuthEmailPasswordShare " + username);
    123                 MailEntry mail = new MailEntry(time, username, colleagueOne, topic, message, options);
    124                 Mail.sendOneOffMail(mail, colleagueOne, Base64.getDecoder().decode(intergalacticNumber));
     124                Mail outbox = MailBay.getMailClient(username);
     125                MailEntry mail = outbox.new MailEntry(time, username, trustedUserOne, topic, message, options);
     126                SecretKeySpec key = new SecretKeySpec(Base64.getDecoder().decode(intergalacticNumber), SymmetricAlgorithm);
     127                outbox.sendOneOffMail(mail, trustedUserOne, key);
    125128               
    126129                //      Send secure message to colleague two
    127                 String colleagueTwo = colleagues[1];
    128                 Mail.sendOneOffMail(mail, colleagueTwo, Base64.getDecoder().decode(intergalacticNumber));
     130                String trustedUserTwo = trustedUsers[1];
     131                outbox.sendOneOffMail(mail, trustedUserTwo, key);
    129132               
    130133                String nl = System.getProperty("line.separator");
     
    136139                try {
    137140                        //      Send email with key to colleague one
    138                         String colleagueOneEmail = colleagues[2];
     141                        String colleagueOneEmail = trustedUsers[2];
    139142                        sendEmail(colleagueOneEmail, sb);
    140143                        //      Send email with key to colleague two
    141                         String colleagueTwoEmail = colleagues[3];
     144                        String colleagueTwoEmail = trustedUsers[3];
    142145                        sendEmail(colleagueTwoEmail, sb);
    143146                       
     
    250253        }
    251254
    252         public static void setPWColleagues(String colleagueOne, String colleagueTwo) {
     255        public static void setPWColleagues(String trustedUserOne, String trustedUserTwo) {
    253256                // Get needed text items.
    254257                Frame pwRecoveryFrame = FrameIO.LoadFrame(UserSettings.UserName.get() + AuthenticatorBrowser.PASSWORD_RECOVERY_FRAME);
     
    261264                        Text text = it.next();
    262265                        if (text.getText().toLowerCase().startsWith("user_one:")) {
    263                                 text.setText("User_one: " + colleagueOne);
    264                                 Colleagues.User_One.set(colleagueOne);
     266                                text.setText("User_one: " + trustedUserOne);
     267                                Colleagues.User_One.set(trustedUserOne);
    265268                        } else if (text.getText().toLowerCase().startsWith("user_two:")) {
    266                                 text.setText("User_two: " + colleagueTwo);
    267                                 Colleagues.User_Two.set(colleagueTwo);
     269                                text.setText("User_two: " + trustedUserTwo);
     270                                Colleagues.User_Two.set(trustedUserTwo);
    268271                        }
    269272                }
     
    281284                // Create shares
    282285                Map<Integer, byte[]> shares = scheme.split(keyBytes);
    283                 String colleagueOneShare = Base64.getEncoder().encodeToString(shares.get(1));
    284                 String colleagueTwoShare = Base64.getEncoder().encodeToString(shares.get(2));
     286                String trustedUserOneShare = Base64.getEncoder().encodeToString(shares.get(1));
     287                String trustedUserTwoShare = Base64.getEncoder().encodeToString(shares.get(2));
    285288               
    286289                // Distribute share zero to colleague one
    287                 String time = org.expeditee.stats.Formatter.getDateTime();
     290                String time = Mail.FORMAT.format(new Date());
    288291                String sender = UserSettings.UserName.get();
    289292                String topic = "Please help me secure my Expeditee account.";
    290293                String message = "Run the below action to store a secret key that will help me recover access to my account should I ever loose it.";
    291294                Map<String, String> options = new HashMap<String, String>();
    292                 options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + colleagueOneShare);
    293                 MailEntry mail = new MailEntry(time, sender, colleagueOne, topic, message, options);
    294                 Mail.sendMail(mail, colleagueOne);
     295                options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + trustedUserOneShare);
     296                Mail outbox = MailBay.getMailClient();
     297                MailEntry mail = outbox.new MailEntry(time, sender, trustedUserOne, topic, message, options);
     298                outbox.sendMail(mail, trustedUserOne);
    295299               
    296300                // Distribute share one to colleague two
    297301                options = new HashMap<String, String>();
    298                 options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + colleagueTwoShare);
    299                 mail = new MailEntry(time, sender, colleagueTwo, topic, message, options);
    300                 Mail.sendMail(mail, colleagueTwo);
    301                
    302                 MessageBay.displayMessage("You PW Colleagues have been set to " + colleagueOne + " and " + colleagueTwo + ".  "
     302                options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + trustedUserTwoShare);
     303                mail = outbox.new MailEntry(time, sender, trustedUserTwo, topic, message, options);
     304                outbox.sendMail(mail, trustedUserTwo);
     305               
     306                MessageBay.displayMessage("You Trusted Users have been set to " + trustedUserOne + " and " + trustedUserTwo + ".  "
    303307                                + "They have been sent a Expeditee mail that they can use to store a share of your secret key.");
    304308        }
Note: See TracChangeset for help on using the changeset viewer.