summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI$1.classbin1106 -> 1106 bytes
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI$2.classbin665 -> 665 bytes
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI$3.classbin677 -> 0 bytes
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI$4.classbin677 -> 677 bytes
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI$5.classbin674 -> 0 bytes
-rw-r--r--Dozentenmodul/bin/gui/intro/Login_GUI.classbin8052 -> 9306 bytes
-rw-r--r--Dozentenmodul/src/gui/intro/Login_GUI.java238
7 files changed, 146 insertions, 92 deletions
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI$1.class b/Dozentenmodul/bin/gui/intro/Login_GUI$1.class
index a064efc0..38603fa8 100644
--- a/Dozentenmodul/bin/gui/intro/Login_GUI$1.class
+++ b/Dozentenmodul/bin/gui/intro/Login_GUI$1.class
Binary files differ
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI$2.class b/Dozentenmodul/bin/gui/intro/Login_GUI$2.class
index 9c179a21..889fe1e3 100644
--- a/Dozentenmodul/bin/gui/intro/Login_GUI$2.class
+++ b/Dozentenmodul/bin/gui/intro/Login_GUI$2.class
Binary files differ
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI$3.class b/Dozentenmodul/bin/gui/intro/Login_GUI$3.class
deleted file mode 100644
index 33e222c7..00000000
--- a/Dozentenmodul/bin/gui/intro/Login_GUI$3.class
+++ /dev/null
Binary files differ
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI$4.class b/Dozentenmodul/bin/gui/intro/Login_GUI$4.class
index 0fa234c1..695118c3 100644
--- a/Dozentenmodul/bin/gui/intro/Login_GUI$4.class
+++ b/Dozentenmodul/bin/gui/intro/Login_GUI$4.class
Binary files differ
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI$5.class b/Dozentenmodul/bin/gui/intro/Login_GUI$5.class
deleted file mode 100644
index c09574b4..00000000
--- a/Dozentenmodul/bin/gui/intro/Login_GUI$5.class
+++ /dev/null
Binary files differ
diff --git a/Dozentenmodul/bin/gui/intro/Login_GUI.class b/Dozentenmodul/bin/gui/intro/Login_GUI.class
index 7f627245..39a6adb3 100644
--- a/Dozentenmodul/bin/gui/intro/Login_GUI.class
+++ b/Dozentenmodul/bin/gui/intro/Login_GUI.class
Binary files differ
diff --git a/Dozentenmodul/src/gui/intro/Login_GUI.java b/Dozentenmodul/src/gui/intro/Login_GUI.java
index e2db747e..3ff5edfd 100644
--- a/Dozentenmodul/src/gui/intro/Login_GUI.java
+++ b/Dozentenmodul/src/gui/intro/Login_GUI.java
@@ -1,6 +1,6 @@
package gui.intro;
-
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Image;
@@ -12,8 +12,8 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
-import java.nio.channels.SeekableByteChannel;
-
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
@@ -25,7 +25,6 @@ import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
-
import models.SessionData;
import models.person;
import org.apache.thrift.TException;
@@ -33,15 +32,19 @@ import org.ini4j.Wini;
import thrift.MasterThriftConnection;
import thrift.ImageServer.Client;
import thrift.UserInfo;
-
import config.config_file;
+import javax.swing.SwingConstants;
@SuppressWarnings("serial")
public class Login_GUI extends JFrame {
private JPanel contentPane;
- private JTextField username;
- private JPasswordField pass;
+ private JTextField lblusername;
+ private JPasswordField lblpass;
+ JLabel lblConnectionInfo = new JLabel("");
+ boolean isConnectionToServerOK = false;
+ boolean login;
+ String masterServerIP = "132.230.4.16";
/**
* Launch the application.
@@ -129,16 +132,16 @@ public class Login_GUI extends JFrame {
contentPane.add(LabelUser);
// Erzeugen und Hinzufügen des Textfeldes
- username = new JTextField();
- username.setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
- username.addActionListener(new ActionListener() {
+ lblusername = new JTextField();
+ lblusername.setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
+ lblusername.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
performLogin();
}
});
- username.setBounds(304, 164, 196, 20);
- contentPane.add(username);
- username.setColumns(10);
+ lblusername.setBounds(304, 164, 196, 20);
+ contentPane.add(lblusername);
+ lblusername.setColumns(10);
// Erzeugen und Hinzufügen des Labels
JLabel LabelPass = new JLabel("bwIDM-Passwort:");
@@ -157,105 +160,156 @@ public class Login_GUI extends JFrame {
contentPane.add(BtnLogin);
// Erzeugen und Hinzufügen des Passwortfeldes
- pass = new JPasswordField();
- pass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
- pass.addActionListener(new ActionListener() {
+ lblpass = new JPasswordField();
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
+ lblpass.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performLogin();
}
});
- pass.setBounds(304, 195, 196, 20);
- contentPane.add(pass);
+ lblpass.setBounds(304, 195, 196, 20);
+ contentPane.add(lblpass);
+
+ lblConnectionInfo.setHorizontalAlignment(SwingConstants.LEFT);
+ lblConnectionInfo.setBounds(304, 290, 196, 20);
+ contentPane.add(lblConnectionInfo);
}// end LoginGUI()
- //Versuche den Benutzer einzuloggen
+ // Versuche den Benutzer einzuloggen
public void performLogin() {
- // Aufruf der Ldap Klasse, welche die Ldap überprüfung vornimmt
- // Ldap check=new Ldap();
- boolean login = true;
- // boolean login=check.LdapAuth(username.getText(), new
- // String(pass.getPassword()));
+ // show user, the client is doing something..
+ lblConnectionInfo.setForeground(Color.red);
+ lblConnectionInfo.setText("Error: Server nicht erreichbar.");
+
+ login = false;
MasterThriftConnection thrift = new MasterThriftConnection();
Client client = thrift.getMasterThriftConnection();
String token = null;
- final thrift.SessionData result;
+ thrift.SessionData result = null;
try {
- String passText = new String(pass.getPassword());
- System.out.println("Benutzer:" +username.getText() + "\nPasswort" + passText);
- result = client.authenticate(username.getText(), passText);
- SessionData.session.setAuthToken(result.authToken);
- SessionData.session.setSessionID(result.sessionId);
- SessionData.session.setServerAdress(result.serverAddress);
- System.out.println("Server Adresse: "+result.serverAddress);
-
- } catch (thrift.AuthenticationException e) {
- System.out.println("Authentifizierung fehlgeschlagen: " + e.message);
- JOptionPane.showMessageDialog(null,
- "Benutzeranmeldung fehlgeschlagen: Bitte Benutzername und Passwort überprüfen.",
- "Anmeldung fehlgeschlagen",
- JOptionPane.ERROR_MESSAGE);
+ login = true;
+ String passText = new String(lblpass.getPassword());
+ System.out.println("Benutzer: " + lblusername.getText()
+ + "\nPasswort: " + passText);
+
+ // check if server can be pinged, true if server reachable
+ if (checkServerConnection() == true) {
+ //server is reachable by ping
+ lblConnectionInfo.setForeground(Color.black);
+ lblConnectionInfo.setText("Verbindung wird aufgebaut...");
+
+ result = client.authenticate(lblusername.getText(), passText);
+ SessionData.session.setAuthToken(result.authToken);
+ SessionData.session.setSessionID(result.sessionId);
+ SessionData.session.setServerAdress(result.serverAddress);
+ System.out.println("Server Adresse: " + result.serverAddress);
+
+ System.out
+ .println("Konnte mich beim MasterServer authentifizieren. Meine Session-ID ist "
+ + result.sessionId
+ + ", mein Token für den Satelliten "
+ + result.authToken);
+ token = result.authToken;
+
+ if (login == true) {
+
+ try {
+ Wini ini = new Wini(
+ new File(
+ "C:\\Users\\"
+ + System.getProperty("user.name")
+ + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini"));
+ // Prüfe ob Bills Of Rights schon akzeptiert wurden, wenn nicht zeige diese an
+ if (ini.get("main", "BillOfRights", boolean.class) == false) {
+ // Erstellen einer Instanz der Aktionsauswahl
+ BillOfRights_GUI re = new BillOfRights_GUI();
+ re.setVisible(true);
+ // Schließen des Fensters nach erfolgreichen Login
+ setVisible(false);
+ } else {
+ // Prüfe ob die Links zu vmware angezeigt werden
+ // sollen
+ if (ini.get("main", "vmware", boolean.class) == false) {
+ VmWareLink_GUI vm = new VmWareLink_GUI();
+ vm.setVisible(true);
+ setVisible(false);
+ } else {
+ UserInfo user = client.getUserFromToken(token);
+
+ String hochschule = user.eMail.substring(
+ user.eMail.indexOf("@") + 1,
+ user.eMail.indexOf(".",
+ user.eMail.indexOf("@")));
+ // System.out.println("hochschule="+hochschule);
+
+ person.verantwortlicher.setUsername(lblusername
+ .getText());
+ person.verantwortlicher.setName(user.lastName);
+ person.verantwortlicher
+ .setVorname(user.firstName);
+ person.verantwortlicher.setEMail(user.eMail);
+ person.verantwortlicher
+ .setHochschule(hochschule);
+
+ // Öffne das Hauprmenü
+ MainMenue_GUI main = new MainMenue_GUI();
+ main.setVisible(true);
+ setVisible(false);
+ }
+ }
+ } catch (IOException | TException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ } else {
+ JOptionPane.showMessageDialog(null, "Login denied!",
+ "Message", JOptionPane.INFORMATION_MESSAGE);
+ }
+ } else {
+ // server not reachable by ping
+ login = false;
+ lblConnectionInfo.setForeground(Color.red);
+ lblConnectionInfo.setText("Error: Server nicht erreichbar.");
+
+ }
+
+ } catch (thrift.AuthenticationException e) {
+ System.out
+ .println("Authentifizierung fehlgeschlagen: " + e.message);
+ JOptionPane
+ .showMessageDialog(
+ null,
+ "Benutzeranmeldung fehlgeschlagen: Bitte Benutzername und Passwort überprüfen.",
+ "Anmeldung fehlgeschlagen",
+ JOptionPane.ERROR_MESSAGE);
return;
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
- System.out
- .println("Konnte mich beim MasterServer authentifizieren. Meine Session-ID ist "
- + result.sessionId
- + ", mein Token für den Satelliten "
- + result.authToken);
- token = result.authToken;
- if (login == true) {
+ }// end performLogin
- try {
- Wini ini = new Wini(new File("C:\\Users\\"
- + System.getProperty("user.name")
- + "\\AppData\\Roaming\\bwLehrpoolSuite\\config.ini"));
- // Prüfe ob Bills Of Rights schon akzeptiert wurden, wenn nicht
- // zeige diese an
- if (ini.get("main", "BillOfRights", boolean.class) == false) {
- // Erstellen einer Instanz der Aktionsauswahl
- BillOfRights_GUI re = new BillOfRights_GUI();
- re.setVisible(true);
- // Schließen des Fensters nach erfolgreichen Login
- setVisible(false);
- } else {
- // Prüfe ob die Links zu vmware angezeigt werden sollen
- if (ini.get("main", "vmware", boolean.class) == false) {
- VmWareLink_GUI vm = new VmWareLink_GUI();
- vm.setVisible(true);
- setVisible(false);
- } else {
- UserInfo user = client.getUserFromToken(token);
-
- String hochschule = user.eMail.substring(user.eMail
- .indexOf("@") + 1, user.eMail.indexOf(".",
- user.eMail.indexOf("@")));
- // System.out.println("hochschule="+hochschule);
-
- person.verantwortlicher.setUsername(username.getText());
- person.verantwortlicher.setName(user.lastName);
- person.verantwortlicher.setVorname(user.firstName);
- person.verantwortlicher.setEMail(user.eMail);
- person.verantwortlicher.setHochschule(hochschule);
-
- // Öffne das Hauprmenü
- MainMenue_GUI main = new MainMenue_GUI();
- main.setVisible(true);
- setVisible(false);
- }
- }
- } catch (IOException | TException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ public boolean checkServerConnection() {
+ try {
+ if (InetAddress.getByName(masterServerIP).isReachable(1000) == true) {
+ isConnectionToServerOK = true;
+ System.out.println("Server " +masterServerIP +" ist erreichbar.");
+ } else {
+ login = false;
+ isConnectionToServerOK = false;
+ System.out.println("Fehler: Server "+masterServerIP +" ist nicht erreicht");
}
-
- } else {
- JOptionPane.showMessageDialog(null, "Login denied!", "Message",
- JOptionPane.INFORMATION_MESSAGE);
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- }// end performLogin
+ return isConnectionToServerOK;
+ }// end checkServerConnection()
}// end class