Index: trunk/src/org/apollo/io/AudioPathManager.java
===================================================================
--- trunk/src/org/apollo/io/AudioPathManager.java	(revision 1302)
+++ trunk/src/org/apollo/io/AudioPathManager.java	(revision 1303)
@@ -12,5 +12,5 @@
 import org.apollo.util.ApolloSystemLog;
 import org.apollo.util.RegExpFileFilter;
-import org.expeditee.gui.Browser;
+import org.expeditee.auth.AuthenticatorBrowser;
 import org.expeditee.gui.FrameIO;
 import org.expeditee.settings.UserSettings;
@@ -45,6 +45,6 @@
 	public static void changeParentAndSubFolders(String newFolder) {
 		
-		if (Boolean.getBoolean("auth") && System.getProperty("user.name").equals(Browser.USER_NOBODY)) {
-			System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + Browser.USER_NOBODY + "'");
+		if (Boolean.getBoolean("auth") && System.getProperty("user.name").equals(AuthenticatorBrowser.USER_NOBODY)) {
+			System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + AuthenticatorBrowser.USER_NOBODY + "'");
 			return;
 		}
Index: trunk/src/org/expeditee/auth/Actions.java
===================================================================
--- trunk/src/org/expeditee/auth/Actions.java	(revision 1302)
+++ trunk/src/org/expeditee/auth/Actions.java	(revision 1303)
@@ -43,4 +43,6 @@
 import org.expeditee.agents.InvalidFramesetNameException;
 import org.expeditee.auth.Mail.MailEntry;
+import org.expeditee.auth.account.Authenticate;
+import org.expeditee.auth.account.Authenticate.AuthenticationResult;
 import org.expeditee.auth.gui.MailBay;
 import org.expeditee.auth.tags.AuthenticationTag;
@@ -185,13 +187,23 @@
 	 * @throws Exception 
 	 */
-	public static void AuthLogin() throws Exception {
+	public static void AuthLogin() {
 		final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
 		final Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
-		if (userdata.isPresent()) { 
-			login(userdata.get());
+		if (userdata.isPresent()) {
+			AuthenticationResult result = Authenticate.login(userdata.get());
+			if (result == AuthenticationResult.SuccessLogin) {
+				MessageBay.displayMessage(result.toString());
+			} else {
+				MessageBay.errorMessage(result.toString());
+			}
+			//login(userdata.get());
 			AuthenticatorBrowser.Authenticated = true;
 		} else {
 			MessageBay.errorMessage(Constants.ERROR_INSUFFICIENT_INFORMATION_PROVIDED);
 		}
+	}
+	
+	public static void AuthLogout() {
+		MessageBay.displayMessage(Authenticate.logout().toString());
 	}
 	
@@ -493,5 +505,5 @@
 		String password = userdata.get(AuthenticationTag.Password);
 		
-		if (username.equals(Browser.USER_NOBODY)) {
+		if (username.equals(AuthenticatorBrowser.USER_NOBODY)) {
 			return;
 		}
Index: trunk/src/org/expeditee/auth/AuthenticatorBrowser.java
===================================================================
--- trunk/src/org/expeditee/auth/AuthenticatorBrowser.java	(revision 1302)
+++ trunk/src/org/expeditee/auth/AuthenticatorBrowser.java	(revision 1303)
@@ -78,4 +78,5 @@
 	
 	private KeyStore keyStore = KeyStore.getInstance(KeystoreType);
+	public static String USER_NOBODY = "nobody";
 		
 	private static final byte[] TRUE = "yes".getBytes();
@@ -95,5 +96,5 @@
 	
 	public static boolean isAuthenticated() {
-		return isAuthenticationRequired() && !UserSettings.UserName.get().equals(Browser.USER_NOBODY);
+		return isAuthenticationRequired() && !UserSettings.UserName.get().equals(AuthenticatorBrowser.USER_NOBODY);
 	}
 	
@@ -225,5 +226,5 @@
 	}
 	
-	final void loadMailDatabase() throws SQLException, FileNotFoundException, ParseException {
+	public final void loadMailDatabase() throws SQLException, FileNotFoundException, ParseException {
 		Path deadDropPath = Paths.get(FrameIO.DEAD_DROPS_PATH);
 		for (File connectionDir: deadDropPath.toFile().listFiles()) {
@@ -239,5 +240,5 @@
 	}
 
-	final void updateLastReadMailTime(Path deaddropforcontactPath) {
+	public final void updateLastReadMailTime(Path deaddropforcontactPath) {
 		Path timestamp = deaddropforcontactPath.resolve(UserSettings.UserName.get() + ".last-accessed");
 		try(FileWriter out = new FileWriter(timestamp.toFile())) {
@@ -304,5 +305,5 @@
 	}
 	 
-	final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {	
+	public final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {	
 		
 		char[] password_ca = password.toCharArray();
@@ -318,5 +319,5 @@
 	}
 	
-	final void putKey(final String label, final String password, final SecretKey key) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
+	public final void putKey(final String label, final String password, final SecretKey key) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
 		final KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(key);
 		final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(password.toCharArray());
@@ -325,5 +326,5 @@
 	}
 	
-	final boolean confirmIntergalaticNumber(final String username, final String email, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
+	public final boolean confirmIntergalaticNumber(final String username, final String email, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
 		try {
 			final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
@@ -341,5 +342,5 @@
 	}
 	
-	final String newIntergalacticNumber(final String username, final String email) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
+	public final String newIntergalacticNumber(final String username, final String email) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
 		// generate intergalactic number
 		final SecureRandom rand = new SecureRandom();
@@ -357,5 +358,5 @@
 	}
 	
-	final PublicKey getPublicKey(String username) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException {
+	public final PublicKey getPublicKey(String username) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException {
 		// load in frame with public key on it.
 		String credentialsFramesetPath = FrameIO.CONTACTS_PATH + username + "-credentials" + File.separator;
@@ -386,5 +387,5 @@
 	}
 	
-	final void markRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
+	public final void markRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
 		KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(TRUE, SymmetricAlgorithm));
 		KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(KeyList.PersonalKey.get().getText().toCharArray());
@@ -393,5 +394,5 @@
 	}
 	
-	final void clearRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
+	public final void clearRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
 		KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(FALSE, SymmetricAlgorithm));
 		KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(KeyList.PersonalKey.get().getText().toCharArray());
@@ -400,5 +401,5 @@
 	}
 	
-	final boolean hasRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException {
+	public final boolean hasRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException {
 		String alias = username + "colleaguesRequested";
 		if (!keyStore.containsAlias(alias)) {
Index: trunk/src/org/expeditee/auth/account/Authenticate.java
===================================================================
--- trunk/src/org/expeditee/auth/account/Authenticate.java	(revision 1303)
+++ trunk/src/org/expeditee/auth/account/Authenticate.java	(revision 1303)
@@ -0,0 +1,194 @@
+package org.expeditee.auth.account;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.InvalidKeyException;
+import java.security.KeyFactory;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+
+import org.expeditee.auth.Actions;
+import org.expeditee.auth.AuthenticatorBrowser;
+import org.expeditee.auth.Mail;
+import org.expeditee.auth.Mail.MailEntry;
+import org.expeditee.auth.gui.MailBay;
+import org.expeditee.auth.tags.AuthenticationTag;
+import org.expeditee.auth.tags.Constants;
+import org.expeditee.gui.Browser;
+import org.expeditee.gui.DisplayController;
+import org.expeditee.gui.Frame;
+import org.expeditee.gui.FrameIO;
+import org.expeditee.gui.MessageBay;
+import org.expeditee.items.Item;
+import org.expeditee.items.Text;
+import org.expeditee.settings.Settings;
+import org.expeditee.settings.UserSettings;
+import org.expeditee.settings.identity.secrets.KeyList;
+import org.ngikm.cryptography.CryptographyConstants;
+
+public class Authenticate implements CryptographyConstants {
+
+	public static AuthenticationResult login(Map<AuthenticationTag, String> userdata) {
+		String username = userdata.get(AuthenticationTag.Username);
+		String password = userdata.get(AuthenticationTag.Password);
+
+		if (username.equals(AuthenticatorBrowser.USER_NOBODY)) {
+			return AuthenticationResult.ErrorLoginNobody;
+		}
+
+		SecretKey personalKey = null;
+		try {
+			personalKey = AuthenticatorBrowser.getInstance().getSecretKey(username, password);
+		} catch (Exception e) {
+			return AuthenticationResult.ErrorLoginUsernamePasswordCombo;
+		}
+		
+		UserSettings.UserName.set(username);
+		if (!username.equals(AuthenticatorBrowser.ADMINACCOUNT)) {
+			// Set the personal key to bootstrap the encrypted frame loading.
+			Text personalKeyText = KeyList.PersonalKey.generateText();
+			personalKeyText.setData(Base64.getEncoder().encodeToString(personalKey.getEncoded()));
+			KeyList.PersonalKey.setSetting(personalKeyText);
+			
+			// Load in and cache the profile frame using the personal key fetched from keystore.
+			FrameIO.ClearCache();
+			Frame oneFrame = FrameIO.LoadProfile(username);
+			for (int i = 1; i <= FrameIO.getLastNumber(oneFrame.getFramesetName()); i++) {
+				Frame f = FrameIO.LoadFrame(oneFrame.getFramesetName() + i);
+				if (f != null && f.getData() != null && f.getData().contains("MultiuserCredentials")) {
+					AuthenticatorBrowser.CREDENTIALS_FRAME = f.getNumber();
+				}
+			}
+			
+			// Update were we get our frames.
+			UserSettings.setupDefaultFolders();
+			MessageBay.updateFramesetLocation();
+			MailBay.disconnect();
+			
+			// Parse the users profile to refresh settings.
+			Text settingsLink = new Text("settings");
+			settingsLink.setLink(oneFrame.getFramesetName() + "2");
+			Settings.parseSettings(settingsLink);
+			
+			// At this point we at least login, but maybe with problems.
+			AuthenticationResult res = AuthenticationResult.SuccessLogin;
+			
+			// Check mail and update last read files.
+			MailBay.clear();
+			try {
+				AuthenticatorBrowser.getInstance().loadMailDatabase();
+				Text keyItem = KeyList.PrivateKey.get();
+				if (keyItem.getData() != null) {
+					// Check mail.
+					String keyEncoded = keyItem.getData().get(0);
+					byte[] keyBytes = Base64.getDecoder().decode(keyEncoded);
+					PrivateKey key = KeyFactory.getInstance(AsymmetricAlgorithm).generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
+					List<MailEntry> mailForLoggingInUser = Mail.getEntries(UserSettings.UserName.get(), key);			
+					for (MailEntry mail: mailForLoggingInUser) {
+						MailBay.addMessage(mail.timestamp, mail.message, mail.message2, mail.options);
+					}
+					
+					// Update last read files.
+					Path deadDropPath = Paths.get(FrameIO.DEAD_DROPS_PATH);
+					for (File connectionDir: deadDropPath.toFile().listFiles()) {
+						if (connectionDir.isDirectory()) {
+							Path deaddropforcontactPath = Paths.get(connectionDir.getAbsolutePath());
+							AuthenticatorBrowser.getInstance().updateLastReadMailTime(deaddropforcontactPath);
+						}
+					}
+				} else {
+					res.additionalInfo.add("No private key present: your communication with other Expeditee users will be limited until this is resolved.");
+				}
+			} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | ClassNotFoundException
+					| SQLException | ParseException | IOException | InvalidKeyException | NoSuchPaddingException | 
+					IllegalBlockSizeException | BadPaddingException e) {
+				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.");
+				e.printStackTrace();
+			} catch (InvalidKeySpecException e) {
+				res.additionalInfo.add("Stored data cannot be used to create a private key.  See exception for more information.");
+				e.printStackTrace();
+			}
+			
+			Collection<Item> usernameFields = Actions.getByData(FrameIO.LoadFrame(Constants.FRAME_MULTIUSER1), "txtUsername");
+			usernameFields.forEach(usernameField -> usernameField.setText(username));
+			
+			Frame requestedFrame = FrameIO.LoadFrame(Browser.getStartFrame());
+			Frame homeFrame = FrameIO.LoadFrame("home1");
+			Frame choice = requestedFrame != null ? requestedFrame : homeFrame != null ? homeFrame : oneFrame;
+			DisplayController.setCurrentFrame(choice, true);
+		}
+		
+		return AuthenticationResult.SuccessLogin;
+	}
+	
+	public static AuthenticationResult logout() {
+		// Set user to nobody.
+		UserSettings.UserName.set(AuthenticatorBrowser.USER_NOBODY);
+		
+		// Update were we get our frames.
+		UserSettings.setupDefaultFolders();
+		MessageBay.updateFramesetLocation();
+		MailBay.disconnect();
+		
+		// Reset all of the settings.
+		Settings.resetAllSettings();
+		
+		// Display login frame
+		Frame auth1 = FrameIO.LoadFrame("authentication1");
+		DisplayController.setCurrentFrame(auth1, true);
+		
+		return AuthenticationResult.SuccessLogout;
+	}
+
+	public enum AuthenticationResult {
+
+		SuccessLogin, SuccessLogout, ErrorLoginNobody, ErrorLoginUsernamePasswordCombo;
+		
+		private List<String> additionalInfo = new ArrayList<String>();
+
+		public String toString() {
+			switch (this) {
+			case SuccessLogin:
+				StringBuilder sb = new StringBuilder();
+				sb.append("Logged in as: " + UserSettings.UserName.get());
+				if (additionalInfo.isEmpty()) {
+					return sb.toString();
+				} else {
+					String nl = System.getProperty("line.separator");
+					sb.append("However: " + nl);
+					for (String info: additionalInfo) {
+						sb.append(info + nl);
+					}
+					return sb.toString();
+				}
+			case SuccessLogout:
+				return "You are now logged out of Expeditee.";
+			case ErrorLoginNobody:
+				return "You cannot log into Expeditee as the user \'nobody\'";
+			case ErrorLoginUsernamePasswordCombo:
+				return "The username + password combination was incorrect.";
+			}
+
+			String message = "Was the list of possible enum results updated without nessasary changes to thh toString() function?";
+			throw new IllegalArgumentException(message);
+		}
+	}
+}
Index: trunk/src/org/expeditee/auth/gui/MailBay.java
===================================================================
--- trunk/src/org/expeditee/auth/gui/MailBay.java	(revision 1302)
+++ trunk/src/org/expeditee/auth/gui/MailBay.java	(revision 1303)
@@ -51,5 +51,5 @@
 	
 	/** The currently logged in user, consulted when deciding if a new FrameCreator is needed. */
-	private static String currentUser = UserSettings.UserName.get();
+	private static String _forUser = UserSettings.UserName.get();
 	
 	/** The link that the preview pane displays pointing towards unprocessed messages. */
@@ -78,4 +78,11 @@
 	public static boolean isPreviewMailItem(Item i) {
 		return _previewMessages.contains(i) || i == _mailLink;
+	}
+	
+	public static void disconnect() {
+		if (_forUser != UserSettings.UserName.get()) {
+			_creator = null;
+			_forUser = UserSettings.UserName.get();
+		}
 	}
 		
@@ -91,6 +98,6 @@
 		
 		// Ensure frame creator
-		if (_creator == null || currentUser != UserSettings.UserName.get()) {
-			currentUser = UserSettings.UserName.get();
+		if (_creator == null || _forUser != UserSettings.UserName.get()) {
+			_forUser = UserSettings.UserName.get();
 			_creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.AppendAfterLastItem, false);
 		}
Index: trunk/src/org/expeditee/gui/Browser.java
===================================================================
--- trunk/src/org/expeditee/gui/Browser.java	(revision 1302)
+++ trunk/src/org/expeditee/gui/Browser.java	(revision 1303)
@@ -149,6 +149,4 @@
 	public static boolean _hasExited = false;
 
-	public static String USER_NOBODY = "nobody";
-	
 	/** A flag which is set once the application is exiting. */
 	protected boolean _isExiting = false;
@@ -168,5 +166,5 @@
 			String starting_user_name = System.getProperty("user.name");
 			System.setProperty("startinguser.name", starting_user_name);
-			System.setProperty("user.name", USER_NOBODY);
+			System.setProperty("user.name", AuthenticatorBrowser.USER_NOBODY);
 		}
 		
Index: trunk/src/org/expeditee/gui/FrameIO.java
===================================================================
--- trunk/src/org/expeditee/gui/FrameIO.java	(revision 1302)
+++ trunk/src/org/expeditee/gui/FrameIO.java	(revision 1303)
@@ -168,6 +168,6 @@
 		if (!UserSettings.PublicAndPrivateResources || !AuthenticatorBrowser.isAuthenticated()) {
 			
-			if (UserSettings.UserName.get().equals(Browser.USER_NOBODY)) {
-				System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+Browser.USER_NOBODY+"'");
+			if (UserSettings.UserName.get().equals(AuthenticatorBrowser.USER_NOBODY)) {
+				System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+AuthenticatorBrowser.USER_NOBODY+"'");
 			}
 			
Index: trunk/src/org/expeditee/gui/MessageBay.java
===================================================================
--- trunk/src/org/expeditee/gui/MessageBay.java	(revision 1302)
+++ trunk/src/org/expeditee/gui/MessageBay.java	(revision 1303)
@@ -224,4 +224,12 @@
 		return displayMessage(message, link, actions, color, displayAlways);
 	}
+	
+	public static void updateFramesetLocation() {
+		if (_forUser != UserSettings.UserName.get()) {
+			_creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.OverrideExistingFrames,
+					false);
+			_forUser = UserSettings.UserName.get();
+		}
+	}
 
 	/** TODO: Comment. cts16 */
@@ -240,5 +248,5 @@
 		return t;
 	}
-
+	
 	/** TODO: Comment. cts16 */
 	private synchronized static Text displayMessage(String message, String link, List<String> actions, Colour color,
@@ -268,5 +276,5 @@
 		_lastMessage = message;
 
-		if (_creator == null || _forUser == null || !_forUser.equals(UserSettings.UserName.get())) {
+		if (_creator == null) {
 			_creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.OverrideExistingFrames,
 					false);
@@ -562,4 +570,3 @@
 		return _status;
 	}
-
 }
Index: trunk/src/org/expeditee/settings/Settings.java
===================================================================
--- trunk/src/org/expeditee/settings/Settings.java	(revision 1302)
+++ trunk/src/org/expeditee/settings/Settings.java	(revision 1303)
@@ -118,4 +118,12 @@
 	            e.printStackTrace();
             }
+		}
+	}
+	
+	public static void resetAllSettings() {
+		for (PageDescriptor pd : _pages.values()) {
+			for (VariableSetting s : pd.settingsList) {
+				s.reset();
+			}
 		}
 	}
