Changeset 1303 for trunk


Ignore:
Timestamp:
04/11/19 15:42:27 (5 years ago)
Author:
bln4
Message:

Moved the static field USER_NOBODY to AuthenticatorBrowser from Browser as it makes more sense there.
Added functionality to log out, equiv to closing Expeditee and starting it again.

Location:
trunk/src/org
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/io/AudioPathManager.java

    r1244 r1303  
    1212import org.apollo.util.ApolloSystemLog;
    1313import org.apollo.util.RegExpFileFilter;
    14 import org.expeditee.gui.Browser;
     14import org.expeditee.auth.AuthenticatorBrowser;
    1515import org.expeditee.gui.FrameIO;
    1616import org.expeditee.settings.UserSettings;
     
    4545        public static void changeParentAndSubFolders(String newFolder) {
    4646               
    47                 if (Boolean.getBoolean("auth") && System.getProperty("user.name").equals(Browser.USER_NOBODY)) {
    48                         System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + Browser.USER_NOBODY + "'");
     47                if (Boolean.getBoolean("auth") && System.getProperty("user.name").equals(AuthenticatorBrowser.USER_NOBODY)) {
     48                        System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + AuthenticatorBrowser.USER_NOBODY + "'");
    4949                        return;
    5050                }
  • trunk/src/org/expeditee/auth/Actions.java

    r1299 r1303  
    4343import org.expeditee.agents.InvalidFramesetNameException;
    4444import org.expeditee.auth.Mail.MailEntry;
     45import org.expeditee.auth.account.Authenticate;
     46import org.expeditee.auth.account.Authenticate.AuthenticationResult;
    4547import org.expeditee.auth.gui.MailBay;
    4648import org.expeditee.auth.tags.AuthenticationTag;
     
    185187         * @throws Exception
    186188         */
    187         public static void AuthLogin() throws Exception {
     189        public static void AuthLogin() {
    188190                final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
    189191                final Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
    190                 if (userdata.isPresent()) {
    191                         login(userdata.get());
     192                if (userdata.isPresent()) {
     193                        AuthenticationResult result = Authenticate.login(userdata.get());
     194                        if (result == AuthenticationResult.SuccessLogin) {
     195                                MessageBay.displayMessage(result.toString());
     196                        } else {
     197                                MessageBay.errorMessage(result.toString());
     198                        }
     199                        //login(userdata.get());
    192200                        AuthenticatorBrowser.Authenticated = true;
    193201                } else {
    194202                        MessageBay.errorMessage(Constants.ERROR_INSUFFICIENT_INFORMATION_PROVIDED);
    195203                }
     204        }
     205       
     206        public static void AuthLogout() {
     207                MessageBay.displayMessage(Authenticate.logout().toString());
    196208        }
    197209       
     
    493505                String password = userdata.get(AuthenticationTag.Password);
    494506               
    495                 if (username.equals(Browser.USER_NOBODY)) {
     507                if (username.equals(AuthenticatorBrowser.USER_NOBODY)) {
    496508                        return;
    497509                }
  • trunk/src/org/expeditee/auth/AuthenticatorBrowser.java

    r1287 r1303  
    7878       
    7979        private KeyStore keyStore = KeyStore.getInstance(KeystoreType);
     80        public static String USER_NOBODY = "nobody";
    8081               
    8182        private static final byte[] TRUE = "yes".getBytes();
     
    9596       
    9697        public static boolean isAuthenticated() {
    97                 return isAuthenticationRequired() && !UserSettings.UserName.get().equals(Browser.USER_NOBODY);
     98                return isAuthenticationRequired() && !UserSettings.UserName.get().equals(AuthenticatorBrowser.USER_NOBODY);
    9899        }
    99100       
     
    225226        }
    226227       
    227         final void loadMailDatabase() throws SQLException, FileNotFoundException, ParseException {
     228        public final void loadMailDatabase() throws SQLException, FileNotFoundException, ParseException {
    228229                Path deadDropPath = Paths.get(FrameIO.DEAD_DROPS_PATH);
    229230                for (File connectionDir: deadDropPath.toFile().listFiles()) {
     
    239240        }
    240241
    241         final void updateLastReadMailTime(Path deaddropforcontactPath) {
     242        public final void updateLastReadMailTime(Path deaddropforcontactPath) {
    242243                Path timestamp = deaddropforcontactPath.resolve(UserSettings.UserName.get() + ".last-accessed");
    243244                try(FileWriter out = new FileWriter(timestamp.toFile())) {
     
    304305        }
    305306         
    306         final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {   
     307        public final SecretKey getSecretKey(final String label, final String password) throws NoSuchAlgorithmException, KeyStoreException {     
    307308               
    308309                char[] password_ca = password.toCharArray();
     
    318319        }
    319320       
    320         final void putKey(final String label, final String password, final SecretKey key) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
     321        public final void putKey(final String label, final String password, final SecretKey key) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
    321322                final KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(key);
    322323                final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(password.toCharArray());
     
    325326        }
    326327       
    327         final boolean confirmIntergalaticNumber(final String username, final String email, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
     328        public final boolean confirmIntergalaticNumber(final String username, final String email, final String intergalacticNumber) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException {
    328329                try {
    329330                        final KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(intergalacticNumber.toCharArray());
     
    341342        }
    342343       
    343         final String newIntergalacticNumber(final String username, final String email) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
     344        public final String newIntergalacticNumber(final String username, final String email) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
    344345                // generate intergalactic number
    345346                final SecureRandom rand = new SecureRandom();
     
    357358        }
    358359       
    359         final PublicKey getPublicKey(String username) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException {
     360        public final PublicKey getPublicKey(String username) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException {
    360361                // load in frame with public key on it.
    361362                String credentialsFramesetPath = FrameIO.CONTACTS_PATH + username + "-credentials" + File.separator;
     
    386387        }
    387388       
    388         final void markRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
     389        public final void markRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
    389390                KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(TRUE, SymmetricAlgorithm));
    390391                KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(KeyList.PersonalKey.get().getText().toCharArray());
     
    393394        }
    394395       
    395         final void clearRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
     396        public final void clearRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
    396397                KeyStore.SecretKeyEntry entry = new KeyStore.SecretKeyEntry(new SecretKeySpec(FALSE, SymmetricAlgorithm));
    397398                KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(KeyList.PersonalKey.get().getText().toCharArray());
     
    400401        }
    401402       
    402         final boolean hasRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException {
     403        public final boolean hasRequestedColleagues(String username) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException {
    403404                String alias = username + "colleaguesRequested";
    404405                if (!keyStore.containsAlias(alias)) {
  • trunk/src/org/expeditee/auth/gui/MailBay.java

    r1295 r1303  
    5151       
    5252        /** The currently logged in user, consulted when deciding if a new FrameCreator is needed. */
    53         private static String currentUser = UserSettings.UserName.get();
     53        private static String _forUser = UserSettings.UserName.get();
    5454       
    5555        /** The link that the preview pane displays pointing towards unprocessed messages. */
     
    7878        public static boolean isPreviewMailItem(Item i) {
    7979                return _previewMessages.contains(i) || i == _mailLink;
     80        }
     81       
     82        public static void disconnect() {
     83                if (_forUser != UserSettings.UserName.get()) {
     84                        _creator = null;
     85                        _forUser = UserSettings.UserName.get();
     86                }
    8087        }
    8188               
     
    9198               
    9299                // Ensure frame creator
    93                 if (_creator == null || currentUser != UserSettings.UserName.get()) {
    94                         currentUser = UserSettings.UserName.get();
     100                if (_creator == null || _forUser != UserSettings.UserName.get()) {
     101                        _forUser = UserSettings.UserName.get();
    95102                        _creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.AppendAfterLastItem, false);
    96103                }
  • trunk/src/org/expeditee/gui/Browser.java

    r1293 r1303  
    149149        public static boolean _hasExited = false;
    150150
    151         public static String USER_NOBODY = "nobody";
    152        
    153151        /** A flag which is set once the application is exiting. */
    154152        protected boolean _isExiting = false;
     
    168166                        String starting_user_name = System.getProperty("user.name");
    169167                        System.setProperty("startinguser.name", starting_user_name);
    170                         System.setProperty("user.name", USER_NOBODY);
     168                        System.setProperty("user.name", AuthenticatorBrowser.USER_NOBODY);
    171169                }
    172170               
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1293 r1303  
    168168                if (!UserSettings.PublicAndPrivateResources || !AuthenticatorBrowser.isAuthenticated()) {
    169169                       
    170                         if (UserSettings.UserName.get().equals(Browser.USER_NOBODY)) {
    171                                 System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+Browser.USER_NOBODY+"'");
     170                        if (UserSettings.UserName.get().equals(AuthenticatorBrowser.USER_NOBODY)) {
     171                                System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+AuthenticatorBrowser.USER_NOBODY+"'");
    172172                        }
    173173                       
  • trunk/src/org/expeditee/gui/MessageBay.java

    r1300 r1303  
    224224                return displayMessage(message, link, actions, color, displayAlways);
    225225        }
     226       
     227        public static void updateFramesetLocation() {
     228                if (_forUser != UserSettings.UserName.get()) {
     229                        _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.OverrideExistingFrames,
     230                                        false);
     231                        _forUser = UserSettings.UserName.get();
     232                }
     233        }
    226234
    227235        /** TODO: Comment. cts16 */
     
    240248                return t;
    241249        }
    242 
     250       
    243251        /** TODO: Comment. cts16 */
    244252        private synchronized static Text displayMessage(String message, String link, List<String> actions, Colour color,
     
    268276                _lastMessage = message;
    269277
    270                 if (_creator == null || _forUser == null || !_forUser.equals(UserSettings.UserName.get())) {
     278                if (_creator == null) {
    271279                        _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.OverrideExistingFrames,
    272280                                        false);
     
    562570                return _status;
    563571        }
    564 
    565572}
  • trunk/src/org/expeditee/settings/Settings.java

    r1280 r1303  
    118118                    e.printStackTrace();
    119119            }
     120                }
     121        }
     122       
     123        public static void resetAllSettings() {
     124                for (PageDescriptor pd : _pages.values()) {
     125                        for (VariableSetting s : pd.settingsList) {
     126                                s.reset();
     127                        }
    120128                }
    121129        }
Note: See TracChangeset for help on using the changeset viewer.