Merge pull request #92 from informatik-ag-ngl/f/user_registration
Added a proper user registration and login process
This commit is contained in:
		@@ -28,5 +28,11 @@
 | 
				
			|||||||
			<attribute name="maven.pomderived" value="true"/>
 | 
								<attribute name="maven.pomderived" value="true"/>
 | 
				
			||||||
		</attributes>
 | 
							</attributes>
 | 
				
			||||||
	</classpathentry>
 | 
						</classpathentry>
 | 
				
			||||||
 | 
						<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
 | 
				
			||||||
 | 
							<attributes>
 | 
				
			||||||
 | 
								<attribute name="maven.pomderived" value="true"/>
 | 
				
			||||||
 | 
								<attribute name="test" value="true"/>
 | 
				
			||||||
 | 
							</attributes>
 | 
				
			||||||
 | 
						</classpathentry>
 | 
				
			||||||
	<classpathentry kind="output" path="target/classes"/>
 | 
						<classpathentry kind="output" path="target/classes"/>
 | 
				
			||||||
</classpath>
 | 
					</classpath>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							@@ -28,7 +28,7 @@
 | 
				
			|||||||
		<dependency>
 | 
							<dependency>
 | 
				
			||||||
			<groupId>com.github.informatik-ag-ngl</groupId>
 | 
								<groupId>com.github.informatik-ag-ngl</groupId>
 | 
				
			||||||
			<artifactId>envoy-common</artifactId>
 | 
								<artifactId>envoy-common</artifactId>
 | 
				
			||||||
			<version>develop-SNAPSHOT</version>
 | 
								<version>e5c67b8</version>
 | 
				
			||||||
		</dependency>
 | 
							</dependency>
 | 
				
			||||||
	</dependencies>
 | 
						</dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,10 @@
 | 
				
			|||||||
package envoy.client.ui;
 | 
					package envoy.client.ui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.awt.*;
 | 
					import java.awt.*;
 | 
				
			||||||
 | 
					import java.awt.event.ItemEvent;
 | 
				
			||||||
 | 
					import java.awt.event.ItemListener;
 | 
				
			||||||
import java.security.NoSuchAlgorithmException;
 | 
					import java.security.NoSuchAlgorithmException;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.swing.*;
 | 
					import javax.swing.*;
 | 
				
			||||||
import javax.swing.border.EmptyBorder;
 | 
					import javax.swing.border.EmptyBorder;
 | 
				
			||||||
@@ -14,6 +17,7 @@ import envoy.data.LoginCredentials;
 | 
				
			|||||||
 * Created: <strong>01.01.2020</strong><br>
 | 
					 * Created: <strong>01.01.2020</strong><br>
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 * @author Kai S. K. Engelbart
 | 
					 * @author Kai S. K. Engelbart
 | 
				
			||||||
 | 
					 * @author Maximilian Käfer
 | 
				
			||||||
 * @since Envoy v0.3-alpha
 | 
					 * @since Envoy v0.3-alpha
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class LoginDialog extends JDialog {
 | 
					public class LoginDialog extends JDialog {
 | 
				
			||||||
@@ -24,6 +28,11 @@ public class LoginDialog extends JDialog {
 | 
				
			|||||||
	private JTextField			textField;
 | 
						private JTextField			textField;
 | 
				
			||||||
	private JPasswordField		passwordField;
 | 
						private JPasswordField		passwordField;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private JPasswordField		repeatPasswordField;
 | 
				
			||||||
 | 
						private JLabel				lblRepeatPassword;
 | 
				
			||||||
 | 
						private GridBagConstraints	gbc_lblRepeatPassword;
 | 
				
			||||||
 | 
						private GridBagConstraints	gbc_repeatPasswordField;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private LoginCredentials credentials;
 | 
						private LoginCredentials credentials;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
@@ -79,16 +88,78 @@ public class LoginDialog extends JDialog {
 | 
				
			|||||||
			gbc_passwordField.gridy	= 1;
 | 
								gbc_passwordField.gridy	= 1;
 | 
				
			||||||
			contentPanel.add(passwordField, gbc_passwordField);
 | 
								contentPanel.add(passwordField, gbc_passwordField);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								lblRepeatPassword				= new JLabel("Repeat Password:");
 | 
				
			||||||
 | 
								gbc_lblRepeatPassword			= new GridBagConstraints();
 | 
				
			||||||
 | 
								gbc_lblRepeatPassword.anchor	= GridBagConstraints.EAST;
 | 
				
			||||||
 | 
								gbc_lblRepeatPassword.insets	= new Insets(0, 0, 0, 5);
 | 
				
			||||||
 | 
								gbc_lblRepeatPassword.gridx		= 0;
 | 
				
			||||||
 | 
								gbc_lblRepeatPassword.gridy		= 2;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								repeatPasswordField = new JPasswordField();
 | 
				
			||||||
 | 
								gbc_repeatPasswordField			= new GridBagConstraints();
 | 
				
			||||||
 | 
								gbc_repeatPasswordField.fill	= GridBagConstraints.HORIZONTAL;
 | 
				
			||||||
 | 
								gbc_repeatPasswordField.gridx	= 1;
 | 
				
			||||||
 | 
								gbc_repeatPasswordField.gridy	= 2;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			JPanel buttonPane = new JPanel();
 | 
								JPanel buttonPane = new JPanel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								JTextPane registerText = new JTextPane();
 | 
				
			||||||
 | 
								registerText.setText("Register?");
 | 
				
			||||||
 | 
								registerText.setFont(new Font("Arial", Font.BOLD, 12));
 | 
				
			||||||
 | 
								registerText.setAlignmentX(LEFT_ALIGNMENT);
 | 
				
			||||||
 | 
								buttonPane.add(registerText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								JCheckBox registerCheckBox = new JCheckBox();
 | 
				
			||||||
 | 
								registerCheckBox.setAlignmentX(LEFT_ALIGNMENT);
 | 
				
			||||||
 | 
								registerCheckBox.addItemListener(new ItemListener() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									@Override
 | 
				
			||||||
 | 
									public void itemStateChanged(ItemEvent e) {
 | 
				
			||||||
 | 
										switch (e.getStateChange()) {
 | 
				
			||||||
 | 
											case ItemEvent.SELECTED:
 | 
				
			||||||
 | 
												contentPanel.add(lblRepeatPassword, gbc_lblRepeatPassword);
 | 
				
			||||||
 | 
												contentPanel.add(repeatPasswordField, gbc_repeatPasswordField);
 | 
				
			||||||
 | 
												setSize(338, 160);
 | 
				
			||||||
 | 
												contentPanel.revalidate();
 | 
				
			||||||
 | 
												contentPanel.repaint();
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											case ItemEvent.DESELECTED:
 | 
				
			||||||
 | 
												if (repeatPasswordField.getParent() == contentPanel) {
 | 
				
			||||||
 | 
													contentPanel.remove(lblRepeatPassword);
 | 
				
			||||||
 | 
													contentPanel.remove(repeatPasswordField);
 | 
				
			||||||
 | 
													setSize(338, 123);
 | 
				
			||||||
 | 
													contentPanel.revalidate();
 | 
				
			||||||
 | 
													contentPanel.repaint();
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
								buttonPane.add(registerCheckBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
 | 
								buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
 | 
				
			||||||
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
 | 
								getContentPane().add(buttonPane, BorderLayout.SOUTH);
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				JButton okButton = new JButton("OK");
 | 
									JButton okButton = new JButton("OK");
 | 
				
			||||||
				okButton.addActionListener((evt) -> {
 | 
									okButton.addActionListener((evt) -> {
 | 
				
			||||||
					try {
 | 
										try {
 | 
				
			||||||
						credentials = new LoginCredentials(textField.getText(), passwordField.getPassword());
 | 
											if (registerCheckBox.isSelected()) {
 | 
				
			||||||
						dispose();
 | 
												if (Arrays.equals(passwordField.getPassword(), repeatPasswordField.getPassword())) {
 | 
				
			||||||
 | 
													credentials = new LoginCredentials(textField.getText(), passwordField.getPassword(), true);
 | 
				
			||||||
 | 
													dispose();
 | 
				
			||||||
 | 
												} else {
 | 
				
			||||||
 | 
													JOptionPane.showMessageDialog(this, "The repeated password is unequal to the origional password!");
 | 
				
			||||||
 | 
													passwordField.setText(null);
 | 
				
			||||||
 | 
													repeatPasswordField.setText(null);
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											} else {
 | 
				
			||||||
 | 
												credentials = new LoginCredentials(textField.getText(), passwordField.getPassword(), false);
 | 
				
			||||||
 | 
												dispose();
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
					} catch (NoSuchAlgorithmException e) {
 | 
										} catch (NoSuchAlgorithmException e) {
 | 
				
			||||||
						e.printStackTrace();
 | 
											e.printStackTrace();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,7 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		final String	text	= value.getText();
 | 
							final String	text	= value.getText();
 | 
				
			||||||
		final String	state	= value.getStatus().toString();
 | 
							final String	state	= value.getStatus().toString();
 | 
				
			||||||
		final String	date	= new SimpleDateFormat("dd.MM.yyyy HH.mm").format(value.getDate());
 | 
							final String	date	= new SimpleDateFormat("dd.MM.yyyy HH.mm").format(value.getCreationDate());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Getting the MessageColor in the Chat of the current theme
 | 
							// Getting the MessageColor in the Chat of the current theme
 | 
				
			||||||
		String textColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat().toHex();
 | 
							String textColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat().toHex();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user