summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/gui/intro/Login_GUI.java
diff options
context:
space:
mode:
authorunknown2014-04-14 14:54:18 +0200
committerunknown2014-04-14 14:54:18 +0200
commitdc547b8c3f743e7a2f4323cc5be996a5c806e0d5 (patch)
treebefcfa35b56eafdb4d08f6d810311814929909e5 /Dozentenmodul/src/gui/intro/Login_GUI.java
parentFehlerhafte Abfrage behoben (diff)
downloadtutor-module-dc547b8c3f743e7a2f4323cc5be996a5c806e0d5.tar.gz
tutor-module-dc547b8c3f743e7a2f4323cc5be996a5c806e0d5.tar.xz
tutor-module-dc547b8c3f743e7a2f4323cc5be996a5c806e0d5.zip
Check eingebaut, ob Verbindungsdaten vom Server empfangen werden
Diffstat (limited to 'Dozentenmodul/src/gui/intro/Login_GUI.java')
-rw-r--r--Dozentenmodul/src/gui/intro/Login_GUI.java74
1 files changed, 40 insertions, 34 deletions
diff --git a/Dozentenmodul/src/gui/intro/Login_GUI.java b/Dozentenmodul/src/gui/intro/Login_GUI.java
index 91516fe5..81fb223b 100644
--- a/Dozentenmodul/src/gui/intro/Login_GUI.java
+++ b/Dozentenmodul/src/gui/intro/Login_GUI.java
@@ -42,9 +42,12 @@ public class Login_GUI extends JFrame {
private JTextField lblusername;
private JPasswordField lblpass;
JLabel lblConnectionInfo = new JLabel("");
- boolean isConnectionToServerOK = false;
+ boolean isClientReturnedCorrectly = false;
boolean login;
String masterServerIP = "132.230.4.16";
+ MasterThriftConnection thrift;
+ Client client;
+ String token;
/**
* Launch the application.
@@ -133,7 +136,8 @@ public class Login_GUI extends JFrame {
// Erzeugen und Hinzufügen des Textfeldes
lblusername = new JTextField();
- lblusername.setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
+ lblusername
+ .setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
lblusername.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
performLogin();
@@ -180,29 +184,31 @@ public class Login_GUI extends JFrame {
// 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;
+ thrift = new MasterThriftConnection();
+ client = thrift.getMasterThriftConnection();
+ token = null;
thrift.SessionData result = null;
+
try {
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
+ // check if client has received a connection with information or a
+ // null package
+ if (checkClientPackage() == true) {
+ // package has information
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("Satellit-Adresse: " + result.serverAddress);
System.out
.println("Konnte mich beim MasterServer authentifizieren. Meine Session-ID ist "
@@ -219,7 +225,9 @@ public class Login_GUI extends JFrame {
"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
+ // 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();
@@ -267,13 +275,13 @@ public class Login_GUI extends JFrame {
"Message", JOptionPane.INFORMATION_MESSAGE);
}
- //} else {
- // server not reachable by ping
- // login = false;
- // lblConnectionInfo.setForeground(Color.red);
- // lblConnectionInfo.setText("Error: Server nicht erreichbar.");
+ } else {
+ // package from server is null
+ login = false;
+ lblConnectionInfo.setForeground(Color.red);
+ lblConnectionInfo.setText("Fehler: Verbindung nicht möglich.");
- //}
+ }
} catch (thrift.AuthenticationException e) {
System.out
@@ -292,23 +300,21 @@ public class Login_GUI extends JFrame {
}
}// end performLogin
- public boolean checkServerConnection() {
- try {
- if (InetAddress.getByName(masterServerIP).isReachable(1000) == true) {
- isConnectionToServerOK = true;
- System.out.println("Server " +masterServerIP +" ist erreichbar.");
- } else {
- isConnectionToServerOK = false;
- System.out.println("Fehler: Server "+masterServerIP +" ist nicht erreicht");
- }
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ public boolean checkClientPackage() {
+ // check if client is null or has been returned with information
+ if (client != null) {
+ // client contains information
+ isClientReturnedCorrectly = true;
+ System.out.println("Server " + masterServerIP
+ + " ist erreichbar, Verbindungsinformationen erhalten");
+ } else {
+ // client has returned with error
+ isClientReturnedCorrectly = false;
+ System.out.println("Fehler: Client " + masterServerIP
+ + " hat keine korrekten Verbindungsdaten erhalten.");
}
- return isConnectionToServerOK;
+
+ return isClientReturnedCorrectly;
}// end checkServerConnection()
}// end class