summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/server/ServerHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/src/main/java/server/ServerHandler.java')
-rw-r--r--dozentenmodulserver/src/main/java/server/ServerHandler.java629
1 files changed, 383 insertions, 246 deletions
diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/server/ServerHandler.java
index 11f7d3ab..0deb1037 100644
--- a/dozentenmodulserver/src/main/java/server/ServerHandler.java
+++ b/dozentenmodulserver/src/main/java/server/ServerHandler.java
@@ -28,8 +28,10 @@ import server.generated.User;
import org.openslx.imagemaster.thrift.iface.ImageServer.Client;
import org.openslx.imagemaster.thrift.iface.InvalidTokenException;
+import org.openslx.imagemaster.thrift.iface.UserInfo;
+
import thrift.MasterThriftConnection;
-import thrift.SessionData;
+//import thrift.SessionData;
import sql.SQL;
@@ -39,30 +41,69 @@ public class ServerHandler implements Server.Iface {
private static Logger log = Logger.getLogger(ServerHandler.class);
static SQL sql = new SQL();
- Client client = null;
+
+ private Map<String,UserInfo> tokenManager = new HashMap<>(); //saves the current tokens and the mapped userdata, returning from the server
- 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) {
+ public boolean authenticated(String token) throws TException
+ {
+ if(tokenManager.get(token) != null)
+ {
+ //user found in tokenManager, session was set to valid once before (cached session, no further action needed)
+ return true;
+ }
+ else
+ {
+ MasterThriftConnection thrift = new MasterThriftConnection();
+ Client client = thrift.getMasterThriftConnection();
+
+ //user not in tokenManager, check authentication, then add user to tokenManager
+ log.info("token is: "+token);
+ UserInfo ui = null;
+ if( (ui = client.getUserFromToken(token)) != null) //user authenticated by masterserver
+ {
+ //user was authenticated by the masterserver, cache the data
+ tokenManager.put(token, ui);
return true;
}
- } catch (TException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- log.info("User not authenticated.");
+
+ return false;
+ }
+
+
+ private UserInfo getUserFromToken(String token) //local function, which gets userdata from the tokenmanager, not the masterserver
+ { //implemented, as there is no need for userdata in each function, so return type of authenticated should stay boolean
+ UserInfo ui = tokenManager.get(token);
+ return ui;
+ }
+
+
+ public boolean setSessionInvalid(String token)
+ {
+ log.info("token disabling.. round one");
+ log.info(tokenManager.get(token));
+
+
+ tokenManager.remove(token);
+
+ log.info("token disabling.. round two");
+ log.info(tokenManager.get(token));
+
+ if(tokenManager.get(token) == null) //check if deletion worked and token isn't stored anymore
+ {
+ return true;
+ }
return false;
+
}
@Override
- public User getFtpUser() throws TException {
- if (authenticated()) {
+ public User getFtpUser(String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
log.info("returning FTPUser...");
User user = new User();
user.setUserName(UUID.randomUUID().toString().substring(0, 8));
@@ -165,45 +206,56 @@ public class ServerHandler implements Server.Iface {
return null;
}
+
@Override
- public long DeleteFtpUser(String user) throws TException {
- if (authenticated()) {
+
+ public long DeleteFtpUser(String user, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.DeleteUser(user);
}
return -1;
}
+
@Override
- public String getPathOfImage(String image_id, String version)
- throws TException {
- if (authenticated()) {
- log.info("successfully returned PathOfImage: "
- + sql.getPathOfImage(image_id, version));
+
+ public String getPathOfImage(String image_id, String version, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ log.info("successfully returned PathOfImage: " + sql.getPathOfImage(image_id, version));
+
return sql.getPathOfImage(image_id, version);
}
return null;
}
@Override
- public String setInstitution(String university)
- throws InvalidTokenException {
- if (authenticated()) {
+ public String setInstitution(String university, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.setInstitution(university);
}
return null;
}
@Override
- public boolean writeVLdata(String imagename, String desc, String login,
- String firstname, String lastname, String university, String Mail,
+ public boolean writeVLdata(String imagename, String desc,
String Tel, String Fak, boolean license, boolean internet,
long ram, long cpu, String imagePath, boolean isTemplate,
- long filesize, long shareMode, String os, String uid)
- throws TException {
-
- if (authenticated()) {
+ long filesize, long shareMode, String os, String uid, String token, String userID) throws TException
+ {
+
+ if(authenticated(token))
+ {
String mode = null;
-
+
+
if (shareMode == 0) {
mode = "only_local";
} else {
@@ -226,8 +278,10 @@ public class ServerHandler implements Server.Iface {
// sql.setImageData(pk_person, license, internet, cpu, ram,
// imagename,desc, imagePath, filesize,mode,pk_os);
- sql.setImageData(login, license, internet, cpu, ram, imagename,
- desc, imagePath, filesize, mode, pk_os, uid);
+ sql.setImageData(userID, license, internet, cpu, ram, imagename, desc,
+ imagePath, filesize, mode, pk_os, uid);
+
+ log.info("userID in serverhandler was: "+userID);
log.info("written VLdata");
return true;
@@ -236,87 +290,125 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public List<Image> getImageListPermissionWrite(String userID)
- throws TException {
- if (authenticated()) {
+
+ public List<Image> getImageListPermissionWrite(String userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.getImageListPermissionWrite(userID);
}
return null;
}
@Override
- public List<Image> getImageListPermissionRead(String userID)
- throws TException {
- if (authenticated()) {
+ public List<Image> getImageListPermissionRead(String userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.getImageListPermissionRead(userID);
}
return null;
}
@Override
- public List<Image> getImageListPermissionLink(String userID)
- throws TException {
- if (authenticated()) {
+ public List<Image> getImageListPermissionLink(String userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.getImageListPermissionLink(userID);
}
return null;
}
@Override
- public List<Image> getImageListPermissionAdmin(String userID)
- throws TException {
- if (authenticated()) {
+ public List<Image> getImageListPermissionAdmin(String userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+
return sql.getImageListPermissionAdmin(userID);
}
return null;
}
@Override
- public List<Image> getImageListAllTemplates() throws TException {
- if (authenticated()) {
+ public List<Image> getImageListAllTemplates(String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getImageListAllTemplates();
}
return null;
}
@Override
- public List<String> getAllOS() throws TException {
- if (authenticated()) {
+ public List<String> getAllOS(String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getAllOS();
}
return null;
}
+ //UserInfo does not return the institution, so in this case, the local method is prepared, but not yet executed, as the institution has to be added to UserInfo (or selected by institutionID)
@Override
- public Map<String, String> getPersonData(String Vorname, String Nachname)
- throws TException {
- if (authenticated()) {
- return sql.getPersonData(Vorname, Nachname);
+ public Map<String, String> getPersonData(String Vorname, String Nachname, String token) throws TException
+ {
+
+ if(authenticated(token))
+ {
+
+ Map<String, String> map = new HashMap<>();
+
+ UserInfo ui = getUserFromToken(token);
+
+ map.put("mail", ui.getEMail());
+ map.put("Nachname", ui.getLastName());
+ map.put("Vorname", ui.getFirstName());
+
+ //map.put("Hochschule", sql.getInstitutionByID(ui.getOrganizationId())); //does not deliver the correct id
+ Map<String, String> tempMap = new HashMap<>();
+ tempMap = sql.getPersonData(Vorname, Nachname);
+ map.put("Hochschule", tempMap.get("Hochschule"));
+
+ return map;
}
return null;
}
- public void setPerson(String login, String lastname, String firstname,
- String mail, String Institution) throws InvalidTokenException {
- if (authenticated()) {
- sql.setPerson(login, lastname, firstname, mail, new Date(),
- Institution);
+
+ public void setPerson(String userID, String token, String institution) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+ //String institution = sql.getInstitutionByID(ui.getOrganizationId());
+ sql.setPerson(userID, ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), institution);
}
}
+
+
@Override
public boolean writeLecturedata(String name, String shortdesc, String desc,
- String startDate, String endDate, boolean isActive, String imageID,
- String login, String firstname, String lastname, String university,
- String Mail, String Tel, String Fak, String lectureID)
- throws TException {
- if (authenticated()) {
-
- // String pk_image = imageID;
+ String startDate, String endDate, boolean isActive,
+ String imageID, String token, String Tel, String Fak, String lectureID, String university)
+ throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+
+ //String pk_image = imageID;
Map<String, String> map = new HashMap<String, String>();
int imageversion = 0;
+ //String university = sql.getInstitutionByID(ui.getOrganizationId());
String pk_institution = sql.setInstitution(university);
- String pk_person = sql.setPerson(login, lastname, firstname, Mail,
+ String pk_person = sql.setPerson(ui.getEMail(), ui.getLastName(), ui.getFirstName(), ui.getEMail(),
new Date(), pk_institution);
map = sql.getImageIDandVersion(imageID);
@@ -332,8 +424,10 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean startFileCopy(String filename) throws TException {
- if (authenticated()) {
+ public boolean startFileCopy(String filename, String token) throws TException
+ {
+ if(authenticated(token))
+ {
// copy file from folder temp to folder prod
String file = Configuration.config.getAbsolute_path() + "temp/"
+ filename;
@@ -359,11 +453,11 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public Map<String, String> getImageData(String imageid, String imageversion)
- throws TException {
- if (authenticated()) {
- // log.info("returning ImageData: "+ sql.getImageData(imageid,
- // imageversion).size() + "items.");
+ public Map<String, String> getImageData(String imageid, String imageversion, String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ //log.info("returning ImageData: "+ sql.getImageData(imageid, imageversion).size() + "items.");
return sql.getImageData(imageid, imageversion);
}
return null;
@@ -373,12 +467,15 @@ public class ServerHandler implements Server.Iface {
public boolean updateImageData(String name, String newName, String desc,
String image_path, boolean license, boolean internet, long ram,
long cpu, String id, String version, boolean isTemplate,
- long filesize, long shareMode, String os) throws TException {
+ long filesize, long shareMode, String os, String token) throws TException
+ {
- if (authenticated()) {
+ if (authenticated(token))
+ {
//get old_image_path
String old_image_path = sql.getFile(id, version);
+
String mode = null;
if (shareMode == 0) {
@@ -407,77 +504,79 @@ public class ServerHandler implements Server.Iface {
}
return false;
}
+
@Override
- public List<Lecture> getLectureList() throws TException {
- if (authenticated()) {
- // log.info("returning LectureList");
+ public List<Lecture> getLectureList(String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ //log.info("returning LectureList");
return sql.getLectureList();
}
return null;
}
@Override
- public List<Lecture> getLectureListPermissionRead(String userID)
- throws InvalidTokenException {
- if (authenticated()) {
- // log.info("returning LectureListRead");
- return sql.getLectureListPermissionRead(userID);
+ public List<Lecture> getLectureListPermissionRead(String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+ //log.info("returning LectureListRead");
+ return sql.getLectureListPermissionRead(ui.getUserId());
}
return null;
}// end getLectureListPermissionRead
@Override
- public List<Lecture> getLectureListPermissionWrite(String userID)
- throws InvalidTokenException {
- if (authenticated()) {
- // log.info("returning LectureListWrite");
- return sql.getLectureListPermissionWrite(userID);
+ public List<Lecture> getLectureListPermissionWrite(String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+ //log.info("returning LectureListWrite");
+ return sql.getLectureListPermissionWrite(ui.getUserId());
}
return null;
}// end getLectureListPermissionRead
@Override
- public List<Lecture> getLectureListPermissionAdmin(String userID)
- throws InvalidTokenException {
- if (authenticated()) {
- // log.info("returning LectureListAdmin");
- return sql.getLectureListPermissionAdmin(userID);
+
+ public List<Lecture> getLectureListPermissionAdmin(String token) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+ //log.info("returning LectureListAdmin");
+ return sql.getLectureListPermissionAdmin(ui.getUserId());
}
return null;
}// end getLectureListPermissionRead
+
@Override
public boolean updateLecturedata(String name, String newName,
String shortdesc, String desc, String startDate, String endDate,
- boolean isActive, String imageid, String imageversion, String user,
- String firstname, String lastname, String university, String Mail,
- String Tel, String Fak, String id) throws TException {
- if (authenticated()) {
- Map<String, String> map = new HashMap<String, String>();
- map = sql.getDeleteXMLData(id);
- sql.updateLectureData(imageid, imageversion, lastname, newName,
- desc, shortdesc, startDate, endDate, isActive, id);
-
- String path = Configuration.config.getAbsolute_path()
- + "prod/"
- + map.get("date")
- .substring(0, map.get("date").length() - 2) + "_"
- + university + "_" + user + "_" + map.get("name") + ".xml";
- File tmpFile = new File(path);
- try {
- FileUtils.forceDelete(tmpFile);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
+ boolean isActive, String imageid, String imageversion, String token,
+ String Tel, String Fak, String id, String university) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+
+ sql.updateLectureData(imageid, imageversion, ui.getLastName(), newName, desc,
+ shortdesc, startDate, endDate, isActive, id);
+
}
return false;
}
@Override
- public boolean deleteImageServer(String imageid, String imageversion)
- throws TException {
- if (authenticated()) {
+ public boolean deleteImageServer(String imageid, String imageversion, String token) throws TException
+ {
+ if(authenticated(token))
+ {
String stringFile = sql.getFile(imageid, imageversion);
log.info("File to Delete: " + stringFile);
@@ -499,76 +598,71 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean deleteImageByPath(String image_path){
+ public boolean deleteImageData(String id, String version, String token) throws TException
+ {
+ boolean success=false;
- try {
- if (authenticated()) {
- //String stringFile = sql.getFile(imageid, imageversion);
- log.info("File to Delete: " + image_path);
-
- File tmpFile = new File(Configuration.config.getAbsolute_path()
- + image_path);
-
- try {
- // File wird von Server gelöscht
- FileUtils.forceDelete(tmpFile);
- return true;
-
- } catch (IOException e) {
- log.info("Failed to execute deleteImageServer.");
- e.printStackTrace();
-
- }
+ if(authenticated(token))
+ {
+ if(sql.deleteImage(id, version)==true)
+ {
+ success=true;
+ log.info("Image '"+id+"' and permissions successfully deleted.");
}
- } catch (InvalidTokenException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- return false;
-
+ return success;
}
+
+//TODO
+public boolean deleteImageByPath(String image_path) throws TException{
- @Override
- public boolean deleteImageData(String id, String version) throws TException {
- boolean success = false;
- if (authenticated()) {
- if (sql.deleteImage(id, version) == true) {
- success = true;
- log.info("Image '" + id
- + "' and permissions successfully deleted.");
+ //String stringFile = sql.getFile(imageid, imageversion);
+ log.info("File to Delete: " + image_path);
+
+ File tmpFile = new File(Configuration.config.getAbsolute_path()
+ + image_path);
+
+ try {
+ // File wird von Server gelöscht
+ FileUtils.forceDelete(tmpFile);
+ return true;
+
+ } catch (IOException e) {
+ log.info("Failed to execute deleteImageServer.");
+ e.printStackTrace();
+
}
- }
- return success;
- }
+
+
+ return false;
+
+}
@Override
- public boolean connectedToLecture(String id, String version)
- throws TException {
- if (authenticated()) {
+ public boolean connectedToLecture(String id, String version, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.connectedToLecture(id, version);
}
return true;
}
- public boolean deleteLecture(String id, String hs, String user)
- throws InvalidTokenException {
+ public boolean deleteLecture(String id, String token, String university) throws TException
+ {
boolean success = false;
+
+ UserInfo ui = getUserFromToken(token);
+
+ String user = ui.getEMail();
+
+ if(authenticated(token))
+ {
+ if(sql.deleteLecture(id) == true)
+ {
- if (authenticated()) {
- /*
- * Map<String, String> map = new HashMap<String, String>(); map =
- * sql.getDeleteXMLData(id); try {
- *
- * String path = Configuration.config.getAbsolute_path() + "prod/" +
- * map.get("date") .substring(0, map.get("date").length() - 2) + "_"
- * + hs + "_" + user + "_" + map.get("name") + ".xml"; File xmlFile
- * = new File(path); FileUtils.forceDelete(xmlFile); } catch
- * (IOException e) { log.info("Failed to execute deleteLecture.");
- * e.printStackTrace(); }
- */
- if (sql.deleteLecture(id) == true) {
success = true;
log.info("Lecture '" + id
+ "' and permissions successfully deleted.");
@@ -579,29 +673,33 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public List<String> getAllUniversities() throws TException {
- if (authenticated()) {
+ public List<String> getAllUniversities(String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getAllUniversities();
}
return null;
}
@Override
- public Map<String, String> getLectureData(String lectureid)
- throws TException {
- if (authenticated()) {
- // log.info("returning LectureData");
+ public Map<String, String> getLectureData(String lectureid, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getLectureData(lectureid);
}
return null;
}
- public static int nthIndexOf(final String string, final String token,
- final int index) {
+ public static int nthIndexOf(final String string, final String searchToken,final int index)
+ {
int j = 0;
- for (int i = 0; i < index; i++) {
- j = string.indexOf(token, j + 1);
+ for (int i = 0; i < index; i++)
+ {
+ j = string.indexOf(searchToken, j + 1);
+
if (j == -1)
break;
}
@@ -610,8 +708,10 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean checkUser(String username) throws TException {
- if (authenticated()) {
+ public boolean checkUser(String username, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.checkUser(username);
}
return false;
@@ -619,33 +719,35 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean createUser(String loginName, String lastName,
- String firstName, String mail, String university) throws TException {
- if (authenticated()) {
+ public boolean createUser(String token, String university) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
String pk_institution = sql.setInstitution(university);
- String pk_person = sql.setPerson(loginName, lastName, firstName,
- mail, new Date(), pk_institution);
+ String pk_person = sql.setPerson(ui.getEMail(), ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), pk_institution);
return true;
}
return false;
}
@Override
- public boolean writeImageRights(String imageID, String username,
- String lastName, String firstName, String mail, String university,
- String role) throws TException {
- if (authenticated()) {
+ public boolean writeImageRights(String imageID, String token,
+ String role, String university, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
String pk_image = null;
Map<String, String> map = new HashMap<String, String>();
- int imageversion = 0;
+
String pk_institution = sql.setInstitution(university);
- String pk_person = sql.setPerson(username, lastName, firstName,
- mail, new Date(), pk_institution);
+ String pk_person = sql.setPerson(userID, ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), pk_institution);
+
map = sql.getImageIDandVersion(imageID);
pk_image = map.get("GUID");
- imageversion = Integer.parseInt(map.get("version"));
if (role.equals("Dozent")) {
int read = 1;
@@ -687,17 +789,16 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean writeLectureRights(String lectureID, String username,
- String lastName, String firstName, String mail, String university,
- String role) throws TException {
- if (authenticated()) {
- // String pk_lecture = null;
-
+ public boolean writeLectureRights(String lectureID, String role, String token, String university, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
+ //String pk_lecture = null;
+ UserInfo ui = getUserFromToken(token);
String pk_institution = sql.setInstitution(university);
- String pk_person = sql.setPerson(username, lastName, firstName,
- mail, new Date(), pk_institution);
- // pk_lecture = sql.getLectureID(lectureID);
-
+ String pk_person = sql.setPerson(userID, ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), pk_institution);
+ //pk_lecture = sql.getLectureID(lectureID);
+
if (role.equals("Dozent")) {
int read = 1;
int write = 1;
@@ -734,9 +835,10 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public List<Person> getAllOtherSatelliteUsers(List<String> userID)
- throws TException {
- if (authenticated()) {
+ public List<Person> getAllOtherSatelliteUsers(List<String> userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getAllOtherSatelliteUsers(userID);
// return null;
}
@@ -746,10 +848,11 @@ public class ServerHandler implements Server.Iface {
// set permissions for users which are !=userID
public boolean writeAdditionalImageRights(String imageID, String userID,
boolean isRead, boolean isWrite, boolean isLinkAllowed,
- boolean isAdmin) throws InvalidTokenException {
+ boolean isAdmin, String token) throws TException
+ {
boolean success = false;
- if (authenticated()) {
-
+ if(authenticated(token))
+ {
Map<String, String> map = new HashMap<String, String>();
map = sql.getImageIDandVersion(imageID);
// String imageID = map.get("GUID");
@@ -762,9 +865,10 @@ public class ServerHandler implements Server.Iface {
}
public boolean writeAdditionalLectureRights(String lectureID,
- String userID, boolean isRead, boolean isWrite, boolean isAdmin)
- throws InvalidTokenException {
- if (authenticated()) {
+ String userID, boolean isRead, boolean isWrite, boolean isAdmin, String token) throws TException
+ {
+ if(authenticated(token))
+ {
Map<String, String> map = new HashMap<String, String>();
// String lectureID = sql.getLectureID(lectureID);
@@ -778,76 +882,95 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public List<Person> getPermissionForUserAndImage(String userID,
- String imageID) throws TException {
- if (authenticated()) {
+ public List<Person> getPermissionForUserAndImage(String token,
+ String imageID, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getPermissionForUserAndImage(userID, imageID);
}
return null;
}
- public List<Person> getPermissionForUserAndLecture(String userID,
- String lectureID) throws InvalidTokenException {
- if (authenticated()) {
+
+ public List<Person> getPermissionForUserAndLecture(String token,String lectureID, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
return sql.getPermissionForUserAndLecture(userID, lectureID);
}
return null;
}
@Override
- public void deleteAllAdditionalImagePermissions(String imageID,
- String userID) throws TException {
- if (authenticated()) {
+ public void deleteAllAdditionalImagePermissions(String imageID, String token, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
sql.deleteAllAdditionalImagePermissions(imageID, userID);
}
return;
}
@Override
- public void deleteAllAdditionalLecturePermissions(String lectureID,
- String userID) throws TException {
- if (authenticated()) {
+ public void deleteAllAdditionalLecturePermissions(String lectureID,String token, String userID) throws TException
+ {
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
sql.deleteAllAdditionalLecturePermissions(lectureID, userID);
}
return;
}
- @Override
- public List<Image> getImageList(String userID) throws TException {
- if (authenticated()) {
+
+ @Override
+ public List<Image> getImageList(String userID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getImageList(userID);
}
return null;
}
@Override
- public List<String> getAdditionalImageContacts(String imageID)
- throws TException {
- if (authenticated()) {
+ public List<String> getAdditionalImageContacts(String imageID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getAdditionalImageContacts(imageID);
}
return null;
}
@Override
- public String getOsNameForGuestOs(String guestOS) throws TException {
- if (authenticated()) {
+ public String getOsNameForGuestOs(String guestOS, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getOsNameForGuestOs(guestOS);
}
return null;
}
@Override
- public String createRandomUUID() throws TException {
- if (authenticated()) {
+ public String createRandomUUID(String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.createRandomUUID();
}
return null;
}
- public Map<String, String> getItemOwner(String itemID) throws TException {
- if (authenticated()) {
+ public Map<String, String> getItemOwner(String itemID, String token) throws TException
+ {
+ if(authenticated(token))
+ {
return sql.getItemOwner(itemID);
}
return null;
@@ -855,23 +978,37 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean userIsImageAdmin(String userID, String imageID)
+ public boolean userIsImageAdmin(String imageID, String token, String userID)
throws TException {
-
- if (authenticated()) {
- return sql.userIsImageAdmin(userID, imageID);
+
+ if(authenticated(token))
+ {
+ UserInfo ui = getUserFromToken(token);
+ return sql.userIsImageAdmin(userID,imageID);
}
return false;
}
@Override
- public boolean userIsLectureAdmin(String userID, String lectureID)
+ public boolean userIsLectureAdmin(String userID, String lectureID, String token)
throws TException {
- if (authenticated()) {
- return sql.userIsLectureAdmin(userID, lectureID);
+
+ if(authenticated(token))
+ {
+ return sql.userIsLectureAdmin(userID,lectureID);
+
}
return false;
}
+
+ @Override
+ public String getInstitutionByID(String institutionID) throws TException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
}// end class