summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/GUI/Login_GUI.java
diff options
context:
space:
mode:
authorunknown2014-03-28 12:49:02 +0100
committerunknown2014-03-28 12:49:02 +0100
commitddd6cc7400e00586d52840deb0ec8df98f69de4a (patch)
tree2e9c2344b0b0d8cdf097adc4020a1b79b68a4793 /Dozentenmodul/src/GUI/Login_GUI.java
parentAuthentifizierung über Masterserver funktioniert nun (diff)
downloadtutor-module-ddd6cc7400e00586d52840deb0ec8df98f69de4a.tar.gz
tutor-module-ddd6cc7400e00586d52840deb0ec8df98f69de4a.tar.xz
tutor-module-ddd6cc7400e00586d52840deb0ec8df98f69de4a.zip
-XML Creator eingebaut
-Dateiname angepasst -> Uploader funktioniert nun wieder
Diffstat (limited to 'Dozentenmodul/src/GUI/Login_GUI.java')
-rw-r--r--Dozentenmodul/src/GUI/Login_GUI.java45
1 files changed, 40 insertions, 5 deletions
diff --git a/Dozentenmodul/src/GUI/Login_GUI.java b/Dozentenmodul/src/GUI/Login_GUI.java
index cc558261..c3987526 100644
--- a/Dozentenmodul/src/GUI/Login_GUI.java
+++ b/Dozentenmodul/src/GUI/Login_GUI.java
@@ -27,7 +27,17 @@ import javax.swing.border.EmptyBorder;
import models.person;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
import org.ini4j.Wini;
+import thrift.AuthenticationException;
+import thrift.ImageServer;
+import thrift.InvalidTokenException;
+import thrift.SessionData;
+import thrift.MasterThriftConnection;
+import thrift.ImageServer.Client;
+import thrift.UserInfo;
import config.config_file;
@@ -145,6 +155,26 @@ public class Login_GUI extends JFrame {
//Ldap check=new Ldap();
boolean login=true;
//boolean login=check.LdapAuth(username.getText(), new String(pass.getPassword()));
+ MasterThriftConnection thrift=new MasterThriftConnection();
+ Client client=thrift.getMasterThriftConnection();
+ String token=null;
+ final thrift.SessionData result;
+ try {
+ String passText = new String(pass.getPassword());
+ System.out.println(username.getText()+" "+passText);
+ result = client.authenticate(username.getText(), passText);
+
+ } catch (thrift.AuthenticationException e) {
+ System.out.println("Authentifizierung fehlgeschlagen: "
+ + e.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)
{
@@ -168,17 +198,22 @@ public class Login_GUI extends JFrame {
}
else
{
- person.verantowrtlicher.setName("Spitzer");
- person.verantowrtlicher.setVorname("Tobias");
- person.verantowrtlicher.setEMail("tspitzer@hs-offenburg.de");
- person.verantowrtlicher.setHochschule("HS Offenburg");
+ UserInfo user=client.getUserFromToken(token);
+
+ String hochschule=user.eMail.substring(user.eMail.indexOf("@")+1,user.eMail.indexOf("."));
+ //System.out.println(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 e) {
+ } catch (IOException | TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}