Changeset 1279 for trunk/src


Ignore:
Timestamp:
04/04/19 11:07:45 (5 years ago)
Author:
bln4
Message:

Stopped exception from being printed to err upon incorrect username+password combination.

When logging in, each user now removes mail from each colleagues database file if the colleague has read it (as determined by the date stored alongside the database file).

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

Legend:

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

    r1277 r1279  
    495495                }
    496496               
    497                 SecretKey personalKey = Authenticator.getInstance().getSecretKey(username, password);
     497                SecretKey personalKey = null;
     498               
     499                try {
     500                        personalKey = Authenticator.getInstance().getSecretKey(username, password);
     501                } catch (Exception e) {
     502                        // leave personalKey null
     503                }
     504
    498505                if (personalKey == null) {
    499506                        // Incorrect username and password
  • trunk/src/org/expeditee/auth/Authenticator.java

    r1278 r1279  
    2929import java.text.ParseException;
    3030import java.text.SimpleDateFormat;
    31 import java.util.ArrayList;
    3231import java.util.Arrays;
    3332import java.util.Base64;
     
    3534import java.util.Date;
    3635import java.util.HashMap;
    37 import java.util.List;
     36import java.util.HashSet;
    3837import java.util.Map;
    3938import java.util.Scanner;
     39import java.util.Set;
    4040import java.util.stream.Stream;
    4141
     
    273273                PreparedStatement query = c.prepareStatement(sql);
    274274                ResultSet allMail = query.executeQuery();
    275                 List<String> oldTimestamps = new ArrayList<String>();
     275                Set<String> oldTimestamps = new HashSet<String>();
    276276               
    277277                while (allMail.next()) {
     
    283283                }
    284284               
    285                 System.err.println("Found " + oldTimestamps.size() + " messages to delete.");
    286                 // TODO delete the messages from database.
     285                if (oldTimestamps.isEmpty()) {
     286                        return;
     287                }
     288               
     289                for(String oldTimestamp: oldTimestamps) {
     290                        System.out.println("Deleting message with timestamp: " + oldTimestamp);
     291                        sql = "DELETE FROM EXPMAIL WHERE time='" + oldTimestamp + "'";
     292                        query = c.prepareStatement(sql);
     293                        query.executeUpdate();
     294                }               
    287295        }
    288296         
     
    295303                        secret_key = (SecretKey) keyStore.getKey(label, password_ca);                   
    296304                } catch (final UnrecoverableEntryException e) {
    297                         e.printStackTrace();
    298                         secret_key = null;
     305                        return null;
    299306                }
    300307               
Note: See TracChangeset for help on using the changeset viewer.