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/Authenticate.java

    r1478 r1504  
    11package org.expeditee.auth.account;
    22
    3 import java.io.IOException;
    4 import java.security.InvalidKeyException;
    5 import java.security.KeyFactory;
    6 import java.security.KeyStoreException;
    7 import java.security.NoSuchAlgorithmException;
    8 import java.security.PrivateKey;
    9 import java.security.cert.CertificateException;
    10 import java.security.spec.InvalidKeySpecException;
    11 import java.security.spec.PKCS8EncodedKeySpec;
    12 import java.sql.SQLException;
    13 import java.text.ParseException;
    143import java.util.ArrayList;
    154import java.util.Base64;
     
    187import java.util.Map;
    198
    20 import javax.crypto.BadPaddingException;
    21 import javax.crypto.IllegalBlockSizeException;
    22 import javax.crypto.NoSuchPaddingException;
    239import javax.crypto.SecretKey;
    2410
     
    9682                        MessageBay.clear();
    9783                        MessageBay.updateFramesetLocation();
    98                         MailBay.disconnect();
     84                        MailBay.reconnectToUser(UserSettings.UserName.get());
    9985                       
    10086                        // Parse the users profile to refresh settings.
     
    10894                        AuthenticationResult res = AuthenticationResult.SuccessLogin;
    10995                       
    110                         // Check mail and update last read files.
    111                         MailBay.clear();
    112                         try {
    113                                 Text keyItem = KeyList.PrivateKey.get();
    114                                 if (keyItem.getData() != null) {
    115                                         // Check mail.
    116                                         String keyEncoded = keyItem.getData().get(0);
    117                                         byte[] keyBytes = Base64.getDecoder().decode(keyEncoded);
    118                                         PrivateKey key = KeyFactory.getInstance(AsymmetricAlgorithm).generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
    119                                         org.expeditee.auth.mail.Mail.checkMail(key);
    120                                 } else {
    121                                         res.additionalInfo.add("No private key present: your communication with other Expeditee users will be limited until this is resolved.");
    122                                 }
    123                         } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | ClassNotFoundException
    124                                         | SQLException | ParseException | IOException | InvalidKeyException | NoSuchPaddingException |
    125                                         IllegalBlockSizeException | BadPaddingException e) {
    126                                 res.additionalInfo.add("An error occured while attempting to load in mail sent to you by other Expeditee users.  See the exception for more information.");
    127                                 e.printStackTrace();
    128                         } catch (InvalidKeySpecException e) {
    129                                 res.additionalInfo.add("Stored data cannot be used to create a private key.  See exception for more information.");
    130                                 e.printStackTrace();
    131                         }
     96                        // Check mail for new user.             
     97                        MailBay.checkMail();
    13298                       
    13399                        Collection<Item> usernameFields = Actions.getByData(FrameIO.LoadFrame("multiuser1"), "txtUsername");
     
    155121                UserSettings.setupDefaultFolders();
    156122                MessageBay.updateFramesetLocation();
    157                 MailBay.disconnect();
    158123               
    159124                // Reset all of the settings.
Note: See TracChangeset for help on using the changeset viewer.