Changeset 1282
- Timestamp:
- 04/05/19 10:24:27 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/auth/AuthenticatorBrowser.java
r1281 r1282 69 69 import org.ngikm.cryptography.CryptographyConstants; 70 70 71 public final class Authenticator extends Browser implements CryptographyConstants {71 public final class AuthenticatorBrowser extends Browser implements CryptographyConstants { 72 72 73 73 // The frame number of the frame containing the current authenticated users public key. … … 83 83 private static final String KEYSTOREFILENAME = "keystore.ks" + File.separator; 84 84 85 private static Authenticator instance;86 87 public static Authenticator getInstance() throws KeyStoreException, FileNotFoundException, NoSuchAlgorithmException, CertificateException, IOException, ClassNotFoundException, SQLException {88 if (instance == null) { instance = new Authenticator (); }85 private static AuthenticatorBrowser instance; 86 87 public static AuthenticatorBrowser getInstance() throws KeyStoreException, FileNotFoundException, NoSuchAlgorithmException, CertificateException, IOException, ClassNotFoundException, SQLException { 88 if (instance == null) { instance = new AuthenticatorBrowser(); } 89 89 return instance; 90 90 } 91 91 92 private Authenticator () throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, ClassNotFoundException, SQLException {92 private AuthenticatorBrowser() throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, ClassNotFoundException, SQLException { 93 93 super("Authentication"); 94 94 UserSettings.setupDefaultFolders(); … … 101 101 // Does the account Authentication.ADMINACCOUNT exist? 102 102 // If not then we have get the user to assign a password to it. 103 if (!keyStore.containsAlias(Authenticator .ADMINACCOUNT)) {103 if (!keyStore.containsAlias(AuthenticatorBrowser.ADMINACCOUNT)) { 104 104 new File(FrameIO.PARENT_FOLDER).mkdirs(); 105 105 protectAdmin(); … … 136 136 // class load database classes 137 137 Class.forName("org.sqlite.JDBC"); 138 _theBrowser = this;139 138 } 140 139 … … 227 226 loadMailFromFile(dbFile); 228 227 } 229 Path timestamp = deaddropforcontactPath.resolve(UserSettings.UserName.get() + ".last-accessed");230 try(FileWriter out = new FileWriter(timestamp.toFile())) {231 out.write(Formatter.getDateTime() + System.getProperty("line.separator"));232 } catch (IOException e) {233 e.printStackTrace();234 }235 228 clearOldMailFromDatabase(deaddropforcontactPath); 236 229 } 230 } 231 } 232 233 final void updateLastReadMailTime(Path deaddropforcontactPath) { 234 Path timestamp = deaddropforcontactPath.resolve(UserSettings.UserName.get() + ".last-accessed"); 235 try(FileWriter out = new FileWriter(timestamp.toFile())) { 236 out.write(Formatter.getDateTime() + System.getProperty("line.separator")); 237 } catch (IOException e) { 238 e.printStackTrace(); 237 239 } 238 240 } … … 257 259 258 260 if (dbFile == null || lastAccessedFile == null) { 259 System.err.println("Failed to clear old messages from database file."); 260 return; // Not the end of the world if we cannot clear out old messages. 261 return; // Not the end of the world if we cannot clear out old messages, these files may not be present yet if the others are recently new. 261 262 } 262 263 … … 266 267 timestamp = format.parse(in.nextLine()); 267 268 } catch (ParseException e) { 268 System.err.println("Failed to clear old messages from database file."); 269 return; // Not the end of the world if we cannot clear out old messages. 269 return; // Not the end of the world if we cannot clear out old messages, the database might be empty. 270 270 } 271 271 -
trunk/src/org/expeditee/gui/Browser.java
r1281 r1282 32 32 import org.expeditee.actions.Simple; 33 33 import org.expeditee.agents.mail.MailSession; 34 import org.expeditee.auth.AuthenticatorBrowser; 34 35 import org.expeditee.core.BlockingRunnable; 35 36 import org.expeditee.core.Colour; … … 204 205 if (Boolean.getBoolean("auth")) { 205 206 try { 206 org.expeditee.auth.Authenticator.getInstance(); 207 _initComplete = true; 208 return; 207 _theBrowser = AuthenticatorBrowser.getInstance(); 209 208 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException | ClassNotFoundException | SQLException e) { 210 209 e.printStackTrace(); 211 210 } 212 } 213 _theBrowser = new Browser(); 211 } else { 212 _theBrowser = new Browser(); 213 } 214 214 215 215 EcosystemManager.getGraphicsManager().requestFocus(); 216 216 217 // Java's way of getting access to internet. Authenticating the user with their proxy username and password. 217 218 Authenticator.setDefault(proxyAuth); 218 219
Note:
See TracChangeset
for help on using the changeset viewer.