diff --git a/client/src/main/java/online/screen/AccountSettingsDialog.java b/client/src/main/java/online/screen/AccountSettingsDialog.java
index 09a6b5d..c36b843 100644
--- a/client/src/main/java/online/screen/AccountSettingsDialog.java
+++ b/client/src/main/java/online/screen/AccountSettingsDialog.java
@@ -57,6 +57,7 @@ public AccountSettingsDialog(String username, String email)
okCancelPanel.add(btnChangePassword);
okCancelPanel.add(btnCancel);
textFieldUsername.setEditable(false);
+ textFieldEmail.setEditable(false);
btnChangePassword.addActionListener(this);
btnOk.addActionListener(this);
@@ -78,54 +79,6 @@ private void init()
textFieldEmail.setText(email);
}
- private boolean valid()
- {
- String newEmail = textFieldEmail.getText();
- if (email.equals(newEmail))
- {
- return true;
- }
-
- if (newEmail == null || newEmail.isEmpty())
- {
- String question = "Are you sure you want to unset your email address?";
- question += "\n\nIf you forget your password you will not be able to regain access to your account.";
- int option = DialogUtil.showQuestion(question, false);
- return option == JOptionPane.YES_OPTION;
- }
-
- return AccountUtil.validateEmail(newEmail);
- }
-
- private void saveNewAccountDetails()
- {
- String newEmail = textFieldEmail.getText();
- if (email.equals(newEmail))
- {
- dispose();
- return;
- }
-
- boolean sendTestEmail = false;
- if (!newEmail.isEmpty())
- {
- String question = "Would you like to send a test email to your new account?";
- int option = DialogUtil.showQuestion(question, false);
- sendTestEmail = option == JOptionPane.YES_OPTION;
- }
-
- Document message = XmlBuilderClient.factoryChangeEmailRequest(username, email, newEmail, sendTestEmail);
- MessageUtil.sendMessage(message, 0);
- }
-
- public void emailChangedSuccessfully()
- {
- EntropyLobby lobby = ScreenCache.getEntropyLobby();
- lobby.setEmail(textFieldEmail.getText());
- DialogUtil.showInfoLater("Account settings changed successfully.");
- disposeLater();
- }
-
@Override
public void actionPerformed(ActionEvent arg0)
{
@@ -140,10 +93,7 @@ public void actionPerformed(ActionEvent arg0)
}
else if (source == btnOk)
{
- if (valid())
- {
- saveNewAccountDetails();
- }
+ dispose();
}
else if (source == btnCancel)
{
@@ -154,16 +104,4 @@ else if (source == btnCancel)
Debug.stackTrace("Unexpected actionPerformed: " + source);
}
}
-
- private void disposeLater()
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- @Override
- public void run()
- {
- dispose();
- }
- });
- }
}
diff --git a/client/src/main/java/online/screen/LoginDialog.java b/client/src/main/java/online/screen/LoginDialog.java
index 124ab2c..45c6ac1 100644
--- a/client/src/main/java/online/screen/LoginDialog.java
+++ b/client/src/main/java/online/screen/LoginDialog.java
@@ -65,14 +65,8 @@ public LoginDialog()
getContentPane().add(lblCreateAccount);
lblCreateAccount.setForeground(Color.BLUE);
lblCreateAccount.setFont(new Font("Tahoma", Font.BOLD, 12));
- lblForgottenPassword.setHorizontalAlignment(SwingConstants.CENTER);
- lblForgottenPassword.setForeground(Color.BLUE);
- lblForgottenPassword.setFont(new Font("Tahoma", Font.BOLD, 12));
- lblForgottenPassword.setBounds(51, 111, 150, 20);
- getContentPane().add(lblForgottenPassword);
lblCreateAccount.addMouseListener(this);
- lblForgottenPassword.addMouseListener(this);
btnLogin.addActionListener(this);
btnCancel.addActionListener(this);
}
@@ -82,7 +76,6 @@ public LoginDialog()
private final JLabel lblPassword = new JLabel("Password");
private final JPasswordField passwordField = new JPasswordField();
private final JLabel lblCreateAccount = new JLabel("Create Account");
- private final JLabel lblForgottenPassword = new JLabel("Forgotten Password");
private final JButton btnLogin = new JButton("Log In");
private final JButton btnCancel = new JButton("Cancel");
@@ -140,46 +133,7 @@ private void sendLoginMessage()
DialogUtil.showErrorLater("Unable to initiate request.");
}
}
-
- private void resetPassword()
- {
- String username = "";
- while (username == null || username.isEmpty())
- {
- if (username == null)
- {
- return;
- }
-
- username = JOptionPane.showInputDialog(this, "Please enter your username", "Reset Password", JOptionPane.PLAIN_MESSAGE);
- }
-
- String email = "";
- while (email == null || email.isEmpty())
- {
- if (email == null)
- {
- return;
- }
-
- email = JOptionPane.showInputDialog(this, "Please enter the email for this account", "Reset Password", JOptionPane.PLAIN_MESSAGE);
- }
-
- boolean success = XmlBuilderClient.sendSymmetricKeyRequest();
- if (success)
- {
- ScreenCache.showConnectingDialog();
- Document resetPasswordRequest = XmlBuilderClient.factoryResetPasswordRequest(username, email);
- MessageUtil.sendMessage(resetPasswordRequest, 0, 0);
- }
- else
- {
- DialogUtil.showErrorLater("Unable to initiate request.");
- }
- }
-
-
-
+
/**
* MouseListener
*/
@@ -198,10 +152,6 @@ public void mouseClicked(MouseEvent arg0)
dialog.setResizable(false);
dialog.setVisible(true);
}
- else if (source == lblForgottenPassword)
- {
- resetPassword();
- }
}
@Override
public void mouseEntered(MouseEvent arg0)
@@ -241,16 +191,4 @@ else if (source == btnCancel)
Debug.stackTrace("Unexpected source for ActionListener: " + source);
}
}
-
- public void disposeLater()
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- @Override
- public void run()
- {
- dispose();
- }
- });
- }
}
diff --git a/client/src/main/java/online/util/ResponseHandler.java b/client/src/main/java/online/util/ResponseHandler.java
index e6e606d..103151f 100644
--- a/client/src/main/java/online/util/ResponseHandler.java
+++ b/client/src/main/java/online/util/ResponseHandler.java
@@ -58,14 +58,6 @@ else if (responseName.equals(RESPONSE_TAG_CHANGE_PASSWORD))
{
handleChangePasswordResponse(root);
}
- else if (responseName.equals(RESPONSE_TAG_CHANGE_EMAIL))
- {
- handleChangeEmailResponse(root);
- }
- else if (responseName.equals(RESPONSE_TAG_RESET_PASSWORD))
- {
- handleResetPasswordResponse(root);
- }
else if (responseName.equals(RESPONSE_TAG_CONNECT_SUCCESS))
{
handleConnectSuccess(root, lobby);
@@ -177,39 +169,6 @@ private static void handleChangePasswordResponse(Element root)
}
}
- private static void handleChangeEmailResponse(Element root)
- {
- AccountSettingsDialog changeEmailDialog = ScreenCache.getAccountSettingsDialog();
-
- String error = root.getAttribute("Error");
- if (!error.isEmpty())
- {
- DialogUtil.showErrorLater(error);
- }
- else
- {
- changeEmailDialog.emailChangedSuccessfully();
- }
- }
-
- private static void handleResetPasswordResponse(Element root)
- {
- ScreenCache.dismissConnectingDialog();
-
- String failureReason = root.getAttribute("FailureReason");
- if (!failureReason.isEmpty())
- {
- DialogUtil.showErrorLater(failureReason);
- }
- else
- {
- String successMessage = "Password reset successfully."
- + "\n\nYour new password has been sent to the email address provided.";
-
- DialogUtil.showInfoLater(successMessage);
- }
- }
-
private static void handleConnectSuccess(Element root, final EntropyLobby lobby)
{
ScreenCache.dismissConnectingDialog();
diff --git a/client/src/main/java/online/util/XmlBuilderClient.java b/client/src/main/java/online/util/XmlBuilderClient.java
index 7dde4fe..2afc0b6 100644
--- a/client/src/main/java/online/util/XmlBuilderClient.java
+++ b/client/src/main/java/online/util/XmlBuilderClient.java
@@ -130,19 +130,6 @@ public static Document factoryChangePasswordRequest(String username, String oldP
return document;
}
- public static Document factoryChangeEmailRequest(String username, String oldEmail, String newEmail, boolean sendTest)
- {
- Document document = XmlUtil.factoryNewDocument();
- Element rootElement = document.createElement(ROOT_TAG_CHANGE_EMAIL_REQUEST);
- rootElement.setAttribute("Username", username);
- rootElement.setAttribute("EmailOld", oldEmail);
- rootElement.setAttribute("EmailNew", newEmail);
- XmlUtil.setAttributeBoolean(rootElement, "SendTest", sendTest);
-
- document.appendChild(rootElement);
- return document;
- }
-
public static Document factoryConnectionRequest(String username, String passwordHash, boolean mobile)
{
Document document = XmlUtil.factoryNewDocument();
@@ -156,17 +143,6 @@ public static Document factoryConnectionRequest(String username, String password
return document;
}
- public static Document factoryResetPasswordRequest(String username, String email)
- {
- Document document = XmlUtil.factoryNewDocument();
- Element rootElement = document.createElement(ROOT_TAG_RESET_PASSWORD_REQUEST);
- rootElement.setAttribute("Username", username);
- rootElement.setAttribute("Email", email);
-
- document.appendChild(rootElement);
- return document;
- }
-
public static Document factoryDisconnectRequest(String username)
{
Document document = XmlUtil.factoryNewDocument();
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index b5a2465..30543e5 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -7,7 +7,6 @@ plugins {
ktfmt { kotlinLangStyle() }
dependencies {
- implementation("javax.mail:javax.mail-api:1.6.2")
implementation("javax.activation:activation:1.1.1")
testImplementation(project(":test-core"))
}
diff --git a/core/src/main/java/util/EmailUtil.java b/core/src/main/java/util/EmailUtil.java
deleted file mode 100644
index b7c18d7..0000000
--- a/core/src/main/java/util/EmailUtil.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.activation.FileDataSource;
-import javax.mail.*;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-public class EmailUtil
-{
- private static final int MAX_ATTACHMENTS_TO_EMAIL = 10;
-
- public static void sendEmail(String title, String message, String targetEmail,
- String fromUsername, String fromPassword, ArrayList attachments) throws MessagingException
- {
- if (message.isEmpty())
- {
- Debug.append("Not sending email " + title + " as body is empty");
- return;
- }
-
- //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
- final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
-
- // Get a Properties object
- Properties props = System.getProperties();
- props.setProperty("mail.smtps.host", "smtp.gmail.com");
- props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
- props.setProperty("mail.smtp.socketFactory.fallback", "false");
- props.setProperty("mail.smtp.port", "465");
- props.setProperty("mail.smtp.socketFactory.port", "465");
- props.setProperty("mail.smtps.auth", "true");
-
- Session session = Session.getInstance(props, null);
-
- MimeMessage msg = new MimeMessage(session);
-
- msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(targetEmail, false));
- msg.setSubject(title);
- msg.setSentDate(new Date());
-
- if (attachments == null
- || attachments.isEmpty())
- {
- msg.setText(message, "utf-8");
- }
- else
- {
- BodyPart messageBodyPart = new MimeBodyPart();
- messageBodyPart.setText(message);
-
- Multipart multipart = new MimeMultipart();
- multipart.addBodyPart(messageBodyPart);
-
- int size = attachments.size();
- if (size > MAX_ATTACHMENTS_TO_EMAIL)
- {
- Debug.append("Only emailing the first " + MAX_ATTACHMENTS_TO_EMAIL + " attachments (had " + size + ")");
- size = MAX_ATTACHMENTS_TO_EMAIL;
- }
-
- for (int i=0; i