Changeset 1357 for trunk


Ignore:
Timestamp:
05/07/19 14:08:23 (5 years ago)
Author:
bln4
Message:

Fixes to permission on items.

Location:
trunk/src/org/expeditee
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/assets/resources-public/framesets/authentication/4.exp

    r1351 r1357  
    1 V 177
     1V 181
    22p 40
    33U authadmin
    44D 07Jan2019[14:34]
    55M nobody
    6 d 06May2019[11:49]
     6d 07May2019[11:27]
    77B 100 100 39 100
    88Z
     
    167167s 29Apr2019[15:40.59]
    168168d 0 0 0 100
    169 P 2 380
     169P 16 380
    170170e 100 59 59 100
    171171N 380
     
    179179s 29Apr2019[15:40.59]
    180180d 0 0 0 100
    181 P 977 380
     181P 991 380
    182182e 100 59 59 100
    183183N 380
     
    205205M 300
    206206h 1.0
     207p 44
    207208_ph Password Piece Two
    208209
     
    224225M 300
    225226h 1.0
     227p 44
    226228_ph Password Piece One
    227229
     
    301303Z
    302304
    303 ActiveTime:01:24:42
     305ActiveTime:01:24:43
    304306DarkTime:02:32:46
    305 49:58:429 719 350 Ld
    306 49:58:430 719 350 Rd
    307 49:58:932 719 350 Ru
    308 49:59:027 719 350 Lu
    309 50:00:284 905 338 Md
    310 50:00:355 905 338 Rd
    311 50:00:508 905 338 Mu
    312 50:00:523 905 338 Ru
    313 50:05:239 1187 159 Md
    314 50:05:308 1187 159 Rd
    315 50:05:484 1187 159 Ru
    316 50:05:485 1187 159 Mu
     30727:47:127 281 438 Ld
     30827:47:238 281 438 Rd
     30927:47:374 281 438 Ru
     31027:47:382 281 438 Lu
     31127:48:551 629 275 Rd
     31227:48:646 629 275 Ru
     31327:51:670 129 185 Md
     31427:51:790 129 185 Mu
     31527:52:711 137 262 Md
     31627:52:919 137 258 Mu
     31727:53:574 142 203 Md
     31827:53:734 142 203 Mu
     31928:03:310 1265 166 kSHIFT
     32028:03:810 1265 166 kSHIFT
     32128:03:843 1265 166 kSHIFT
     32228:03:876 1265 166 kSHIFT
     32328:03:909 1265 166 kSHIFT
     32428:03:942 1265 166 kSHIFT
     32528:03:975 1265 166 kSHIFT
     32628:03:982 1265 166 kA
     32728:04:310 1278 166 kU
     32828:04:478 1287 166 kT
     32928:04:574 1292 166 kH
     33028:04:798 1301 166 kSHIFT
     33128:04:894 1301 166 kA
     33228:05:158 1314 166 kD
     33328:05:390 1323 166 kM
     33428:05:919 1337 166 kBACKSPACE
     33528:06:419 1323 166 kBACKSPACE
     33628:06:458 1314 166 kBACKSPACE
     33728:06:489 1301 166 kBACKSPACE
     33828:06:520 1292 166 kBACKSPACE
     33928:06:551 1287 166 kBACKSPACE
     34028:06:583 1278 166 kBACKSPACE
     34128:06:616 1265 166 kBACKSPACE
     34228:06:649 1265 166 kBACKSPACE
     34328:06:682 1265 166 kBACKSPACE
     34428:06:694 1265 166 kSHIFT
     34528:06:846 1265 166 kT
     34628:07:048 1276 166 kO
     34728:07:230 1285 166 kG
     34828:07:374 1294 166 kG
     34928:07:439 1303 166 kL
     35028:07:582 1308 166 kE
     35128:07:734 1316 166 kSHIFT
     35228:07:806 1316 166 kA
     35328:08:031 1329 166 kU
     35428:08:174 1338 166 kT
     35528:08:287 1343 166 kH
     35628:08:639 1352 166 kCTRL
     35728:08:799 1352 166 kA
     35828:10:503 1327 164 Md
     35928:10:677 1327 164 Mu
     36028:11:576 1264 173 Md
     36128:11:701 1261 173 Mu
     36228:16:638 1268 163 kSHIFT
     36328:16:902 1268 163 kT
     36428:17:206 1279 163 kO
     36528:17:470 1288 163 kG
     36628:17:614 1297 163 kG
     36728:17:718 1306 163 kL
     36828:17:854 1311 163 kE
     36928:18:006 1319 163 kSHIFT
     37028:18:094 1319 163 kA
     37128:18:261 1332 163 kU
     37228:18:430 1341 163 kT
     37328:18:470 1346 163 kH
     37428:18:742 1355 163 kCTRL
     37528:18:918 1355 163 kA
     37628:20:975 1318 166 Ld
     37728:21:118 1318 166 Lu
     37828:26:463 802 382 Md
     37928:26:638 802 382 Mu
     38028:28:223 802 382 kALT
     38128:28:631 802 382 kRIGHT_ARROW
     38228:44:544 816 382 Md
     38328:44:766 816 382 Mu
     38428:47:295 1281 159 Md
     38528:47:559 1281 159 Rd
     38628:47:910 1281 159 Ru
     38728:47:958 1281 159 Mu
  • trunk/src/org/expeditee/auth/Actions.java

    r1348 r1357  
    2222import java.util.Collection;
    2323import java.util.HashMap;
     24import java.util.Iterator;
    2425import java.util.List;
    2526import java.util.Map;
     
    3839import org.expeditee.auth.account.Authenticate.AuthenticationResult;
    3940import org.expeditee.auth.account.Create;
     41import org.expeditee.auth.account.Create.CreateResult;
    4042import org.expeditee.auth.account.Password;
    4143import org.expeditee.auth.gui.MailBay;
     
    4951import org.expeditee.items.Text;
    5052import org.expeditee.settings.UserSettings;
     53import org.expeditee.settings.identity.passwordrecovery.Colleagues;
    5154import org.expeditee.settings.identity.secrets.KeyList;
    5255import org.expeditee.stats.Formatter;
     
    7881                Mail.sendMail(mail, recipient);
    7982                MessageBay.displayMessage("Test message sent.");
     83        }
     84        public static void SetPWColleagues(String colleagueOne, String colleagueTwo) {
     85                Colleagues.Colleague_One.set(colleagueOne);
     86                Colleagues.Colleague_Two.set(colleagueTwo);
     87                Colleagues.Colleague_One_Email.set("[email protected]");
     88                Colleagues.Colleague_Two_Email.set("[email protected]");
    8089        }
    8190       
     
    181190                        }
    182191                       
    183                         Create.createAccount(userData);
    184                         Authenticate.login(userData);
    185                         AuthenticatorBrowser.Authenticated = true;
     192                        CreateResult result = Create.createAccount(userData);
     193                        if (result == CreateResult.SuccessCreateAccount) {
     194                                Authenticate.login(userData);
     195                                AuthenticatorBrowser.Authenticated = true;
     196                        } else {
     197                                MessageBay.errorMessage(result.toString());
     198                        }
    186199                } else {
    187200                        MessageBay.errorMessage("Please fill out all the supplied text boxes.");
     
    196209         */
    197210        public static void AuthLogin() {
    198                 final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
    199                 final Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
     211                Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
     212                Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
    200213                if (userdata.isPresent()) {
    201214                        AuthenticationResult result = Authenticate.login(userdata.get());
    202215                        if (result == AuthenticationResult.SuccessLogin) {
    203216                                MessageBay.displayMessage(result.toString());
     217                                AuthenticatorBrowser.Authenticated = true;
    204218                        } else {
    205219                                MessageBay.errorMessage(result.toString());
    206220                        }
    207                         //login(userdata.get());
    208                         AuthenticatorBrowser.Authenticated = true;
    209221                } else {
    210222                        MessageBay.errorMessage("Please fill out all the supplied text boxes.");
     
    258270        }
    259271       
    260         public static void AuthResetPasswordPt1() {
     272        public static void AuthDistributeIntergalacticNumber() {
    261273                Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
    262                 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username);
     274                Optional<Map<AuthenticationTag, String>> userdata =
     275                                AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username);
    263276                if (userdata.isPresent()) {
    264277                        Map<AuthenticationTag, String> userData = userdata.get();
     
    267280                        userData.put(AuthenticationTag.Email, email);
    268281                        Password.generateAndDeliverIntergalacticNumber(userData);
    269                         MessageBay.displayMessage("A Intergalactic number has been sent to the email associated with your account.  Enter it below to proceed.");
    270                 }
    271         }
    272        
    273         public static void AuthResetPasswordPt2() {
     282                        MessageBay.displayMessage("A identity number has been sent to the email "
     283                                        + "associated with your account.  Enter it below to proceed.");
     284                }
     285        }
     286       
     287        public static void AuthSubmitIntergalacticNumber() {
    274288                Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
    275                 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username,
    276                                 AuthenticationTag.IntergalacticNumber, AuthenticationTag.NewPassword, AuthenticationTag.NewPasswordAgain);
     289                Optional<Map<AuthenticationTag, String>> userdata =
     290                                AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username,
     291                                                AuthenticationTag.IntergalacticNumber);
    277292                if (userdata.isPresent()) {
    278                         Map<AuthenticationTag, String> userData = userdata.get();
    279                         String username = userData.get(AuthenticationTag.Username);
    280                         String email = getEmailFromUsername(username);
    281                         userData.put(AuthenticationTag.Email, email);
    282                         Password.confirmIntergalacticNumberAndGenerateSubstituteAccount(userData);
     293                        Map<AuthenticationTag, String> tags = userdata.get();
     294                        String username = tags.get(AuthenticationTag.Username);
     295                        String intergalacticNumber = tags.get(AuthenticationTag.IntergalacticNumber);
     296                        boolean match = false;
     297                        try {
     298                                match = AuthenticatorBrowser.getInstance().confirmIntergalaticNumber(username, intergalacticNumber);
     299                        } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | ClassNotFoundException
     300                                        | IOException | SQLException e) {
     301                                e.printStackTrace();
     302                                return;
     303                        }
     304                        if (!match) {
     305                                MessageBay.errorMessage("The provided identity number does not match the one stored on file.");
     306                                return;
     307                        }
     308                        String[] colleagues = getPasswordColleaguesFromUsername(username);
     309                        Password.confirmIntergalacticNumberAndAlertColleagues(userdata.get(), colleagues);
    283310                }
    284311        }
    285312       
    286313        private static String getEmailFromUsername(String username) {
    287                 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
    288314                Path credentialsDirPath = Paths.get(FrameIO.PROFILE_PATH).resolve(username).resolve(username + "-credentials");
    289315                Path credentialsFilePath = credentialsDirPath.resolve("credentials.inf");
     
    303329                int number = Integer.parseInt(fileName.replace(".exp", ""));
    304330                Frame credentialsFrame = FrameIO.LoadFrame(username + number, FrameIO.PROFILE_PATH);
    305                 textItems = credentialsFrame.getTextItems();
     331                Collection<Text> textItems = credentialsFrame.getTextItems();
    306332                textItems.removeIf(text -> !text.getText().startsWith("Email: "));
    307333                if (textItems.isEmpty()) {
     
    313339                        return email;
    314340                }
     341        }
     342       
     343        private static String[] getPasswordColleaguesFromUsername(String username) {
     344                Path credentialsDirPath = Paths.get(FrameIO.PROFILE_PATH).resolve(username).resolve(username + "-credentials");
     345                Path credentialsFilePath = credentialsDirPath.resolve("pwcolleagues.inf");
     346                String fileName = null;
     347                if (credentialsFilePath.toFile().exists()) {
     348                        try (Scanner in = new Scanner(credentialsFilePath)) {
     349                                fileName = in.nextLine();
     350                        } catch (IOException e) {
     351                                MessageBay.errorMessage("Unable to password colleague frame for specified user, are they registered on this computer?");
     352                                return null;
     353                        }
     354                } else {
     355                        MessageBay.errorMessage("Unable to password colleague frame for specified user, are they registered on this computer?");
     356                        return null;
     357                }
     358               
     359                int number = Integer.parseInt(fileName.replace(".exp", ""));
     360                Frame pwColleagueFrame = FrameIO.LoadFrame(username + number, FrameIO.PROFILE_PATH);
     361                Collection<Text> textItems = pwColleagueFrame.getTextItems();
     362                textItems.removeIf(text -> !text.getText().startsWith("Colleague"));
     363               
     364                String[] ret = new String[4];
     365                Iterator<Text> it = textItems.iterator();
     366                while(it.hasNext()) {
     367                        String content = it.next().getText().toLowerCase().trim();
     368                        if (content.contains("colleague_one:")) {
     369                                ret[0] = content.replace("colleague_one:", "").trim();
     370                        } else if (content.contains("colleague_two:")) {
     371                                ret[1] = content.replace("colleague_two:", "").trim();
     372                        } else if (content.contains("colleague_one_email:")) {
     373                                ret[2] = content.replace("colleague_one_email:", "").trim();
     374                        } else if (content.contains("colleague_two_email:")) {
     375                                ret[3] = content.replace("colleague_two_email:", "").trim();
     376                        }
     377                }
     378                return ret;
    315379        }
    316380       
  • trunk/src/org/expeditee/auth/AuthenticatorBrowser.java

    r1352 r1357  
    151151                        FileNotFoundException, IOException {
    152152                // Fetch desired password
     153                @SuppressWarnings("resource")
    153154                Scanner in = new Scanner(System.in);
    154155                System.out.println("No administrative password set.");
     
    164165                                // Register account.
    165166                                putKey(ADMINACCOUNT, password, new SecretKeySpec("null".getBytes(), AsymmetricAlgorithm));
    166                                 in.close();
     167                                //in.close();
    167168                                passwordIsSet = true;
    168169                                break;
     
    327328        }
    328329       
    329         public final boolean confirmIntergalaticNumber(final String username, final String email, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
     330        public final boolean confirmIntergalaticNumber(final String username, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
    330331                try {
    331                         final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
    332                         final KeyStore.SecretKeyEntry entry = (SecretKeyEntry) keyStore.getEntry(email + username, entryPassword);
    333                         if (entry == null) { 
     332                        KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
     333                        KeyStore.SecretKeyEntry entry = (SecretKeyEntry) keyStore.getEntry(username + "_IntergalacticNumber", entryPassword);
     334                        if (entry == null) {
    334335                                return false;
    335336                        } else if (Arrays.equals(entry.getSecretKey().getEncoded(), TRUE)) {
    336                                 keyStore.deleteEntry(email + username);
     337                                keyStore.deleteEntry(username + "_IntergalacticNumber");
    337338                                keyStore.store(new FileOutputStream(FrameIO.PARENT_FOLDER + KEYSTOREFILENAME), "ExpediteeAuthPassword".toCharArray());
    338339                                return true;
    339                         } else { return false; }
     340                        } else {
     341                                return false;
     342                        }
    340343                } catch (final UnrecoverableEntryException e) {
    341344                        return false;
     
    351354               
    352355                // store intergalactic number
    353                 final KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(TRUE, SymmetricAlgorithm));
    354                 final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
    355                 keyStore.setEntry(email + username, entry, entryPassword);
     356                KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(TRUE, SymmetricAlgorithm));
     357                KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
     358                keyStore.setEntry(username + "_IntergalacticNumber", entry, entryPassword);
    356359                keyStore.store(new FileOutputStream(FrameIO.PARENT_FOLDER + KEYSTOREFILENAME), "ExpediteeAuthPassword".toCharArray());
    357360               
  • trunk/src/org/expeditee/auth/Mail.java

    r1320 r1357  
    3333import javax.crypto.IllegalBlockSizeException;
    3434import javax.crypto.NoSuchPaddingException;
     35import javax.crypto.SecretKey;
     36import javax.crypto.spec.SecretKeySpec;
    3537
    3638import org.expeditee.auth.gui.MailBay;
     
    5456        }
    5557       
     58        public static void sendOneOffMail(MailEntry mail, String colleagueName, byte[] key) {
     59                // Ensure dead drop area is set up.
     60                Path databaseFileDirPath = ensureDeadDrops(colleagueName);
     61               
     62                // Ensure the database file exists.
     63                Path databaseFilePath = ensureDatabaseFile(colleagueName, databaseFileDirPath);
     64               
     65                // Create secret key.
     66                SecretKey secretKey = new SecretKeySpec(key, SymmetricAlgorithm);
     67               
     68                // Send message
     69                sendMail(mail, secretKey, databaseFilePath);
     70        }
     71       
    5672        public static void sendMail(MailEntry mail, String colleagueName) {
    5773                // Ensure dead drop area is set up.
    58                 String me = UserSettings.UserName.get().toLowerCase();
    59                 String them = colleagueName.toLowerCase();
    60                 Path databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(me + "+" + them);
    61                 if (!databaseFileDirPath.toFile().exists()) {
    62                         databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(them + "+" + me);
    63                 }
     74                Path databaseFileDirPath = ensureDeadDrops(colleagueName);
     75               
     76                // Ensure the database file exists.
     77                Path databaseFilePath = ensureDatabaseFile(colleagueName, databaseFileDirPath);
     78               
     79                // Obtain public key
     80                PublicKey publicKey = null;
     81                try {
     82                        publicKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueName);
     83                } catch (InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException | CertificateException
     84                                | ClassNotFoundException | IOException | SQLException e) {
     85                        System.err.println("Error while sending message.  Unable to obtain public key for colleague " + 
     86                                colleagueName + ".  Exception message: " + e.getMessage());
     87                        return;
     88                }
     89               
     90                // Check we got public key
     91                if (publicKey == null) {
     92                        System.err.println("Error while sending message.  Unable to obtain public key for colleague.  Have you exchanged contact details?");
     93                        return;
     94                }
     95               
     96                // Send message
     97                sendMail(mail, publicKey, databaseFilePath);
     98        }
     99
     100        private static Path ensureDatabaseFile(String colleagueName, Path databaseFileDirPath) {
    64101                Path databaseFilePath = databaseFileDirPath.resolve(colleagueName + ".db");
    65102                File databaseFile = databaseFilePath.toFile();
     
    86123                        }
    87124                }
    88                
    89                 // Obtain public key
    90                 PublicKey publicKey = null;
    91                 try {
    92                         publicKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueName);
    93                 } catch (InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException | CertificateException
    94                                 | ClassNotFoundException | IOException | SQLException e) {
    95                         System.err.println("Error while sending message.  Unable to obtain public key for colleague " + 
    96                                 colleagueName + ".  Exception message: " + e.getMessage());
    97                         return;
    98                 }
    99                
    100                 // Check we got public key
    101                 if (publicKey == null) {
    102                         System.err.println("Error while sending message.  Unable to obtain public key for colleague.  Have you exchanged contact details?");
    103                         return;
    104                 }
    105                
    106                 // Send message
    107                 sendMail(mail, publicKey, databaseFilePath);
     125                return databaseFilePath;
     126        }
     127
     128        private static Path ensureDeadDrops(String colleagueName) {
     129                String me = UserSettings.UserName.get().toLowerCase();
     130                String them = colleagueName.toLowerCase();
     131                Path databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(me + "+" + them);
     132                if (!databaseFileDirPath.toFile().exists()) {
     133                        databaseFileDirPath = Paths.get(FrameIO.DEAD_DROPS_PATH).resolve(them + "+" + me);
     134                }
     135                return databaseFileDirPath;
    108136        }
    109137       
     
    111139                try {
    112140                        Cipher cipher = Cipher.getInstance(AsymmetricAlgorithm + AsymmetricAlgorithmParameters);
    113                        
    114                         // encrypt the necessary parts of the message
    115                         //cipher.init(Cipher.ENCRYPT_MODE, key);
    116                         //String time = Base64.getEncoder().encodeToString(cipher.doFinal(mail.timestamp.getBytes()));
    117141                        cipher.init(Cipher.ENCRYPT_MODE, key);
    118142                        String sender = Base64.getEncoder().encodeToString(cipher.doFinal(mail.sender.getBytes()));
     
    134158                       
    135159                        // write to mail database
    136                         Connection c = DriverManager.getConnection("jdbc:sqlite:" + databaseFile);
    137                         String sql = "INSERT INTO EXPMAIL (TIME,SND,REC,MSG,MSG2,OPTS,OPTSVAL) VALUES (?, ?, ?, ?, ?, ?, ?);";
    138                         PreparedStatement statement = c.prepareStatement(sql);
    139                         statement.setString(1, mail.timestamp);
    140                         statement.setString(2, sender);
    141                         statement.setString(3, rec);
    142                         statement.setString(4, message);
    143                         statement.setString(5, message2);
    144                         String opts = Arrays.toString(options.keySet().toArray());
    145                         statement.setString(6, opts);
    146                         String optsval = Arrays.toString(options.values().toArray());
    147                         statement.setString(7, optsval);
    148                         statement.execute();
    149                         statement.close();
    150                         c.close();                     
     160                        writeToMailDatabase(mail, databaseFile, sender, rec, message, message2, options);                       
    151161                } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException | SQLException e) {
    152162                        e.printStackTrace();
     
    154164        }
    155165       
     166        private static void sendMail(MailEntry mail, SecretKey key, Path databaseFile) {
     167                try {
     168                        //      Encrypt message.
     169                        Cipher cipher = Cipher.getInstance(SymmetricAlgorithm + SymmetricAlgorithmParameters);
     170                        cipher.init(Cipher.ENCRYPT_MODE, key);
     171                        String sender = "=" + Base64.getEncoder().encodeToString(cipher.doFinal(mail.sender.getBytes()));
     172                        cipher.init(Cipher.ENCRYPT_MODE, key);
     173                        String rec = Base64.getEncoder().encodeToString(cipher.doFinal(mail.receiver.getBytes()));
     174                        cipher.init(Cipher.ENCRYPT_MODE, key);
     175                        String message = Base64.getEncoder().encodeToString(cipher.doFinal(mail.message.getBytes()));
     176                        cipher.init(Cipher.ENCRYPT_MODE, key);
     177                        String message2 = Base64.getEncoder().encodeToString(cipher.doFinal(mail.message2.getBytes()));                 
     178                        Map<String, String> options = new HashMap<String, String>();
     179                        for (String label: mail.options.keySet()) {
     180                                cipher.init(Cipher.ENCRYPT_MODE, key);
     181                                String labelEncrypted = Base64.getEncoder().encodeToString(cipher.doFinal(label.getBytes()));
     182                                cipher.init(Cipher.ENCRYPT_MODE, key);
     183                                String actionNameEncrypted = Base64.getEncoder().encodeToString(cipher.doFinal(mail.options.get(label).getBytes()));
     184                                options.put(labelEncrypted, actionNameEncrypted);
     185                        }
     186                       
     187                        //      Write to mail database.
     188                        writeToMailDatabase(mail, databaseFile, sender, rec, message, message2, options);
     189                } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException | SQLException e) {
     190                        e.printStackTrace();
     191                }
     192        }
     193
     194        private static void writeToMailDatabase(MailEntry mail, Path databaseFile, String sender, String rec,
     195                        String message, String message2, Map<String, String> options) throws SQLException {
     196                Connection c = DriverManager.getConnection("jdbc:sqlite:" + databaseFile);
     197                String sql = "INSERT INTO EXPMAIL (TIME,SND,REC,MSG,MSG2,OPTS,OPTSVAL) VALUES (?, ?, ?, ?, ?, ?, ?);";
     198                PreparedStatement statement = c.prepareStatement(sql);
     199                statement.setString(1, mail.timestamp);
     200                statement.setString(2, sender);
     201                statement.setString(3, rec);
     202                statement.setString(4, message);
     203                statement.setString(5, message2);
     204                String opts = Arrays.toString(options.keySet().toArray());
     205                statement.setString(6, opts);
     206                String optsval = Arrays.toString(options.values().toArray());
     207                statement.setString(7, optsval);
     208                statement.execute();
     209                statement.close();
     210                c.close();
     211        }
     212               
    156213        /**
    157214         * Gets the mail messages that the specified user is able to read.
     
    230287                public String message2;
    231288                public Map<String, String> options;
     289                public MailEntry subEntry;
    232290               
    233291                public MailEntry(String timestamp, String sender, String rec, String message, String message2, Map<String, String> options) {
  • trunk/src/org/expeditee/auth/account/Password.java

    r1348 r1357  
    2424import org.expeditee.gui.FrameIO;
    2525import org.expeditee.gui.MessageBay;
     26import org.ngikm.cryptography.CryptographyConstants;
    2627
    27 public class Password {
     28public class Password implements CryptographyConstants {
    2829        /*
    2930         * Changes the recorded password for a user in the key store.
     
    9192        }
    9293       
    93         public static void confirmIntergalacticNumberAndGenerateSubstituteAccount(Map<AuthenticationTag, String> userData) {
    94                 String username = userData.get(AuthenticationTag.Username);
    95                 String email = userData.get(AuthenticationTag.Email);
    96                 String intergalacticNumber = userData.get(AuthenticationTag.IntergalacticNumber);
    97                 String newPassword = userData.get(AuthenticationTag.NewPassword);
    98                 String newPasswordAgain = userData.get(AuthenticationTag.NewPasswordAgain);
    99                
    100                 try {
    101                         boolean match = AuthenticatorBrowser.getInstance().confirmIntergalaticNumber(username, email, intergalacticNumber);             
    102                         if (match) {
    103                                 MessageBay.displayMessage(":)");
    104                         } else {
    105                                 MessageBay.displayMessage(":(");
    106                         }
    107                 } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | ClassNotFoundException
    108                                 | IOException | SQLException e) {
    109                         e.printStackTrace();
    110                 }
     94        public static void confirmIntergalacticNumberAndAlertColleagues(Map<AuthenticationTag, String> userData, String[] colleagues) {
     95                System.err.println("Colleague One: " + colleagues[0] + " @" + colleagues[2]);
     96                System.err.println("Colleague Two: " + colleagues[1] + " @" + colleagues[3]);
    11197        }
    11298}
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1354 r1357  
    127127        public static final int MAX_CACHE = 100;
    128128        private static HashMap<String, Frame> _Cache = new FrameCache();
    129         private static boolean ENABLE_CACHE = true;
     129        private static final boolean ENABLE_CACHE = true;
    130130        private static boolean _UseCache = true;
    131131        private static boolean _SuspendedCache = false;
Note: See TracChangeset for help on using the changeset viewer.