diff options
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql/SQL.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/sql/SQL.java | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index 24292c11..94478ac6 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -15,9 +15,16 @@ import java.util.List; import java.util.Map;
import java.util.UUID;
+import org.openslx.imagemaster.thrift.iface.ImageServer.Client;
+import org.openslx.imagemaster.thrift.iface.InvalidTokenException;
+
+//import server.generated.Server.Client;
+
+
import models.Configuration;
import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
import server.BinaryListener;
import server.generated.Image;
@@ -26,9 +33,33 @@ import server.generated.Person; public class SQL {
+
private static Logger log = Logger.getLogger(BinaryListener.class);
+ Client client = null;
+ public void setTokenForSession(String token)
+ {
+ SessionData.session.setAuthToken(token);
+ }
+
+
+ public boolean authenticated() throws InvalidTokenException
+ {
+ MasterThriftConnection thrift = new MasterThriftConnection();
+ client = thrift.getMasterThriftConnection();
+ try {
+ if(client.getUserFromToken(SessionData.session.getAuthToken()) != null)
+ {
+ return true;
+ }
+ } catch (TException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return false;
+ }
+
public Connection getConnection() {
@@ -1001,28 +1032,35 @@ public class SQL { //No prepared statement to do here
- public List<String> getAllOS() {
- List<String> list = new ArrayList<>();
- try {
- Connection con = getConnection();
- Statement stm = con.createStatement();
- ResultSet rs = stm
- .executeQuery("SELECT name, architecture FROM bwLehrpool.m_operatingSystem;");
- while (rs.next()) {
- list.add(rs.getString("name") + " "
- + rs.getString("architecture") + " bit");
+ public List<String> getAllOS() throws InvalidTokenException
+ {
+
+ if(authenticated())
+ {
+ List<String> list = new ArrayList<>();
+ try {
+ Connection con = getConnection();
+ Statement stm = con.createStatement();
+ ResultSet rs = stm
+ .executeQuery("SELECT name, architecture FROM bwLehrpool.m_operatingSystem;");
+ while (rs.next()) {
+ list.add(rs.getString("name") + " "
+ + rs.getString("architecture") + " bit");
+ }
+ return list;
+
+ } catch (SQLException e) {
+
+ log.info("Failed to getAllOS.");
+ e.printStackTrace();
}
- return list;
+
+ return null;
- } catch (SQLException e) {
-
- log.info("Failed to getAllOS.");
- e.printStackTrace();
}
-
return null;
-
}
+
|
