From 9aeb02bd46a8c1d31f26e262f62ad2e6871bc880 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 4 Sep 2019 12:33:19 +0200 Subject: [PATCH 1/4] profiles: Make it possible to use the enter key on the passward field --- .../plugins/profiles/ProfilesPanel.java | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index c4048d516c..160d2ec01d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -26,6 +26,8 @@ package net.runelite.client.plugins.profiles; import java.awt.BorderLayout; import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; @@ -120,6 +122,9 @@ class ProfilesPanel extends PluginPanel txtDecryptPassword.setEchoChar((char) 0); txtDecryptPassword.setForeground(ColorScheme.LIGHT_GRAY_COLOR); txtDecryptPassword.setToolTipText(UNLOCK_PASSWORD); + + txtDecryptPassword.addActionListener(e -> decryptAccounts()); + txtDecryptPassword.addFocusListener(new FocusListener() { @Override @@ -156,27 +161,7 @@ class ProfilesPanel extends PluginPanel @Override public void mousePressed(MouseEvent e) { - boolean error = false; - try - { - redrawProfiles(); - } - catch (InvalidKeySpecException | NoSuchAlgorithmException | IllegalBlockSizeException | InvalidKeyException | BadPaddingException | NoSuchPaddingException ex) - { - error = true; - showErrorMessage("Unable to load data", "Incorrect password!"); - } - - if (error) - { - return; - } - - remove(loginPanel); - add(accountPanel, BorderLayout.CENTER); - - profilesPanel.setLayout(new DynamicGridLayout(0, 1, 0, 3)); - add(profilesPanel, BorderLayout.SOUTH); + decryptAccounts(); } @Override @@ -386,6 +371,31 @@ class ProfilesPanel extends PluginPanel // addAccounts(config.profilesData()); } + private void decryptAccounts() + { + boolean error = false; + try + { + redrawProfiles(); + } + catch (InvalidKeySpecException | NoSuchAlgorithmException | IllegalBlockSizeException | InvalidKeyException | BadPaddingException | NoSuchPaddingException ex) + { + error = true; + showErrorMessage("Unable to load data", "Incorrect password!"); + } + + if (error) + { + return; + } + + remove(loginPanel); + add(accountPanel, BorderLayout.CENTER); + + profilesPanel.setLayout(new DynamicGridLayout(0, 1, 0, 3)); + add(profilesPanel, BorderLayout.SOUTH); + } + private void redrawProfiles() throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException { profilesPanel.removeAll(); From af8fc790677505d196a7f1f1f27fd15f51a1d86e Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 4 Sep 2019 12:36:48 +0200 Subject: [PATCH 2/4] profiles: Check for empty password before redrawing the UI --- .../client/plugins/profiles/ProfilesPanel.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index 160d2ec01d..b1dc2ed5ea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -373,6 +373,12 @@ class ProfilesPanel extends PluginPanel private void decryptAccounts() { + if (txtDecryptPassword.getPassword().length == 0 || String.valueOf(txtDecryptPassword.getPassword()).equals(UNLOCK_PASSWORD)) + { + showErrorMessage("Unable to load data", "Please enter a password!"); + return; + } + boolean error = false; try { @@ -472,11 +478,6 @@ class ProfilesPanel extends PluginPanel String tmp = profilesConfig.profilesData(); if (tmp.startsWith("¬")) { - if (txtDecryptPassword.getPassword().length == 0 || String.valueOf(txtDecryptPassword.getPassword()).equals(UNLOCK_PASSWORD)) - { - showErrorMessage("Unable to load data", "Please enter a password!"); - return tmp; - } tmp = tmp.substring(1); return decryptText(base64Decode(tmp), getAesKey()); } From bb088aeb89eac0623ff3cdba282c5e3de02ae830 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 4 Sep 2019 12:39:53 +0200 Subject: [PATCH 3/4] profiles: Empty the text field when an incorrect password is entered --- .../java/net/runelite/client/plugins/profiles/ProfilesPanel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index b1dc2ed5ea..b4bea3a546 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -388,6 +388,7 @@ class ProfilesPanel extends PluginPanel { error = true; showErrorMessage("Unable to load data", "Incorrect password!"); + txtDecryptPassword.setText(""); } if (error) From 8ce6bea4d215cf78454949bc1123222f463da4ba Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 4 Sep 2019 12:51:38 +0200 Subject: [PATCH 4/4] profiles: Remove unused imports --- .../net/runelite/client/plugins/profiles/ProfilesPanel.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index b4bea3a546..1822a9044e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -26,8 +26,6 @@ package net.runelite.client.plugins.profiles; import java.awt.BorderLayout; import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyAdapter;