summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/sql/SQL.java
diff options
context:
space:
mode:
authorNino Breuer2014-11-28 16:07:58 +0100
committerNino Breuer2014-11-28 16:07:58 +0100
commitc27d50c575ff5867aef8f10ccf2b5f2ac43dae08 (patch)
tree5c2e6586338308ce49e21272931e2341ae7d47ec /dozentenmodulserver/src/main/java/sql/SQL.java
parentMerge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module (diff)
downloadtutor-module-c27d50c575ff5867aef8f10ccf2b5f2ac43dae08.tar.gz
tutor-module-c27d50c575ff5867aef8f10ccf2b5f2ac43dae08.tar.xz
tutor-module-c27d50c575ff5867aef8f10ccf2b5f2ac43dae08.zip
• changed implementation of user authentication.
• changed position of class file • fixed some little things (not necessary to mention) Important Notes: •organizationID in token returns "wrong" values, therefore university is still set by client. To be fixed someday. • userID is the value with which the user starts his log in. this value is not represented in the token! (as it is not(!) the email). To be implemented someday, as this value is represented in the masterserver. • Feature isn't well tested.
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql/SQL.java')
-rw-r--r--dozentenmodulserver/src/main/java/sql/SQL.java64
1 files changed, 52 insertions, 12 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java
index d496489d..9144e4b1 100644
--- a/dozentenmodulserver/src/main/java/sql/SQL.java
+++ b/dozentenmodulserver/src/main/java/sql/SQL.java
@@ -236,7 +236,7 @@ public class SQL {
- public String setPerson(String login, String lastname, String firstname,
+ public String setPerson(String userID, String lastname, String firstname,
String mail, Date lastlogin, String Institution) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try
@@ -258,6 +258,7 @@ public class SQL {
con.commit();
if (ret.next() == false)
{
+ log.info("create user statement values are: userID, loginname, lastname, firstname, mail, institution VALUES: "+userID+" "+userID+" "+lastname+" "+firstname+" "+mail+" "+Institution);
sql = "INSERT INTO `bwLehrpool`.`m_user`(`userID`,`loginName`,`nachname`,`vorname`,`mail`,`lastLogin`,`institution`)VALUES("
+ "?"
@@ -276,8 +277,8 @@ public class SQL {
+ ");";
prest = con.prepareStatement(sql);
- prest.setString(1, login);
- prest.setString(2, login);
+ prest.setString(1, userID);
+ prest.setString(2, userID);
prest.setString(3, lastname);
prest.setString(4, firstname);
prest.setString(5, mail);
@@ -325,10 +326,15 @@ public class SQL {
public boolean setImageData(String pk_person, boolean license,
boolean internet, long cpu, long ram, String imagename,
String desc, String imagePath, long filesize, String shareMode,
- String pk_os, String uid) {
+ String pk_os, String uid)
+ {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ log.info("userID came as pk_person to SQL as: "+pk_person);
+ log.info("pk_os is: "+pk_os);
+ log.info("uid is: "+uid);
+
int internet_bol = 0;
int license_bol = 0;
if (internet == true) {
@@ -1633,8 +1639,9 @@ public class SQL {
- public boolean checkUser(String username) {
- Statement stm;
+ public boolean checkUser(String username)
+ {
+
boolean ret = false;
try {
Connection con = getConnection();
@@ -2000,8 +2007,8 @@ public class SQL {
prest.setString(4, userID);
prest.setBoolean(5, isRead);
prest.setBoolean(6, isWrite);
- prest.setBoolean(7, isAdmin);
- prest.setBoolean(8, isLinkAllowed);
+ prest.setBoolean(7, isLinkAllowed);
+ prest.setBoolean(8, isAdmin);
prest.executeUpdate();
@@ -2095,7 +2102,6 @@ public class SQL {
public void deleteAllAdditionalImagePermissions(String imageID,
String userID) {
Connection con = getConnection();
- Statement stm = null;
try {
@@ -2219,13 +2225,14 @@ public class SQL {
}
-
-
- public boolean userIsImageAdmin(String userID, String imageID) {
+ public boolean userIsImageAdmin(String userID, String imageID)
+ {
Connection con = getConnection();
ResultSet rs = null;
String sql = "SELECT image_admin FROM bwLehrpool.pm_VLData_image WHERE userID= ? AND GUID_imageID=?";
+ log.info("stmt user is image admin: " + "SELECT image_admin FROM bwLehrpool.pm_VLData_image WHERE userID= '"+userID+"' AND GUID_imageID='"+imageID+"'");
+
try
{
PreparedStatement prest = con.prepareStatement(sql);
@@ -2269,6 +2276,39 @@ public class SQL {
}
return false;
}
+
+
+
+
+ public String getInstitutionByID(String institutionID,String errorParam) {
+
+ Connection con = getConnection();
+ ResultSet rs = null;
+ String sql = "SELECT name FROM bwLehrpool.m_institution WHERE institutionID = ?";
+
+ log.info("intitution ID is: "+institutionID);
+
+ PreparedStatement prest;
+ try {
+
+
+ prest = con.prepareStatement(sql);
+ prest.setString(1, institutionID);
+
+ rs = prest.executeQuery();
+ //con.commit();
+ rs.next();
+ return rs.getString("name");
+
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+
+
+ }