summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNino Breuer2014-11-20 14:49:05 +0100
committerNino Breuer2014-11-20 14:49:05 +0100
commitfde3ea91d4ee1d82d376e9feab6cc1b520df7549 (patch)
treeecca9bee92b13851e6c0c74b0ed73f7e549fdb36
parentfdh (diff)
downloadtutor-module-fde3ea91d4ee1d82d376e9feab6cc1b520df7549.tar.gz
tutor-module-fde3ea91d4ee1d82d376e9feab6cc1b520df7549.tar.xz
tutor-module-fde3ea91d4ee1d82d376e9feab6cc1b520df7549.zip
• added dependency to server
• startet implementing user authentication
-rw-r--r--dozentenmodul/pom.xml1
-rw-r--r--dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java7
-rw-r--r--dozentenmodulserver/pom.xml13
-rw-r--r--dozentenmodulserver/src/main/java/server/ServerHandler.java5
-rw-r--r--dozentenmodulserver/src/main/java/server/generated/Server.java728
-rw-r--r--dozentenmodulserver/src/main/java/sql/SQL.java72
-rw-r--r--dozentenmodulserver/thrift/server.thrift1
7 files changed, 809 insertions, 18 deletions
diff --git a/dozentenmodul/pom.xml b/dozentenmodul/pom.xml
index 21be6768..5738de8c 100644
--- a/dozentenmodul/pom.xml
+++ b/dozentenmodul/pom.xml
@@ -266,7 +266,6 @@
<groupId>org.openslx.bwlp</groupId>
<artifactId>master-sync-shared</artifactId>
<version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>bwlehrpool</groupId>
diff --git a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
index 2c7f38f2..8d3c2f21 100644
--- a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
+++ b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java
@@ -57,6 +57,7 @@ import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import models.Links;
+import models.SessionData;
import models.person;
import org.apache.log4j.Logger;
@@ -158,6 +159,12 @@ public class DeleteImage_GUI extends JFrame {
*/
public DeleteImage_GUI(Component formerGUI) {
+ try {
+ client.setTokenForSession(SessionData.session.getAuthToken());
+ } catch (TException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
filters.add(RowFilter.regexFilter(".", 0));
rf = RowFilter.orFilter(filters);
diff --git a/dozentenmodulserver/pom.xml b/dozentenmodulserver/pom.xml
index c9719299..138202b6 100644
--- a/dozentenmodulserver/pom.xml
+++ b/dozentenmodulserver/pom.xml
@@ -14,6 +14,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+ <repositories>
+ <repository>
+ <id>mltk-repo</id>
+ <name>mltk repo</name>
+ <url>http://mltk-services.ruf.uni-freiburg.de:8081/nexus/content/repositories/snapshots/</url>
+ </repository>
+ </repositories>
+
<build>
<plugins>
<plugin>
@@ -119,6 +127,11 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openslx.bwlp</groupId>
+ <artifactId>master-sync-shared</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/server/ServerHandler.java
index 9de342b4..3156ff19 100644
--- a/dozentenmodulserver/src/main/java/server/ServerHandler.java
+++ b/dozentenmodulserver/src/main/java/server/ServerHandler.java
@@ -686,5 +686,10 @@ public class ServerHandler implements Server.Iface {
}
+ @Override
+ public void setTokenForSession(String token) throws TException {
+ sql.setTokenForSession(token);
+ }
+
}// end class
diff --git a/dozentenmodulserver/src/main/java/server/generated/Server.java b/dozentenmodulserver/src/main/java/server/generated/Server.java
index 0a31e033..b827546e 100644
--- a/dozentenmodulserver/src/main/java/server/generated/Server.java
+++ b/dozentenmodulserver/src/main/java/server/generated/Server.java
@@ -38,6 +38,8 @@ public class Server {
public User getFtpUser() throws org.apache.thrift.TException;
+ public void setTokenForSession(String token) throws org.apache.thrift.TException;
+
public long DeleteFtpUser(String user) throws org.apache.thrift.TException;
public String getPathOfImage(String image_id, String version) throws org.apache.thrift.TException;
@@ -130,6 +132,8 @@ public class Server {
public void getFtpUser(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+ public void setTokenForSession(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+
public void DeleteFtpUser(String user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void getPathOfImage(String image_id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
@@ -260,6 +264,26 @@ public class Server {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getFtpUser failed: unknown result");
}
+ public void setTokenForSession(String token) throws org.apache.thrift.TException
+ {
+ send_setTokenForSession(token);
+ recv_setTokenForSession();
+ }
+
+ public void send_setTokenForSession(String token) throws org.apache.thrift.TException
+ {
+ setTokenForSession_args args = new setTokenForSession_args();
+ args.setToken(token);
+ sendBase("setTokenForSession", args);
+ }
+
+ public void recv_setTokenForSession() throws org.apache.thrift.TException
+ {
+ setTokenForSession_result result = new setTokenForSession_result();
+ receiveBase(result, "setTokenForSession");
+ return;
+ }
+
public long DeleteFtpUser(String user) throws org.apache.thrift.TException
{
send_DeleteFtpUser(user);
@@ -1384,6 +1408,38 @@ public class Server {
}
}
+ public void setTokenForSession(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+ checkReady();
+ setTokenForSession_call method_call = new setTokenForSession_call(token, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class setTokenForSession_call extends org.apache.thrift.async.TAsyncMethodCall {
+ private String token;
+ public setTokenForSession_call(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.token = token;
+ }
+
+ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+ prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("setTokenForSession", org.apache.thrift.protocol.TMessageType.CALL, 0));
+ setTokenForSession_args args = new setTokenForSession_args();
+ args.setToken(token);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public void getResult() throws org.apache.thrift.TException {
+ if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ (new Client(prot)).recv_setTokenForSession();
+ }
+ }
+
public void DeleteFtpUser(String user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
DeleteFtpUser_call method_call = new DeleteFtpUser_call(user, resultHandler, this, ___protocolFactory, ___transport);
@@ -3065,6 +3121,7 @@ public class Server {
private static <I extends Iface> Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
processMap.put("getFtpUser", new getFtpUser());
+ processMap.put("setTokenForSession", new setTokenForSession());
processMap.put("DeleteFtpUser", new DeleteFtpUser());
processMap.put("getPathOfImage", new getPathOfImage());
processMap.put("setInstitution", new setInstitution());
@@ -3131,6 +3188,26 @@ public class Server {
}
}
+ public static class setTokenForSession<I extends Iface> extends org.apache.thrift.ProcessFunction<I, setTokenForSession_args> {
+ public setTokenForSession() {
+ super("setTokenForSession");
+ }
+
+ public setTokenForSession_args getEmptyArgsInstance() {
+ return new setTokenForSession_args();
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public setTokenForSession_result getResult(I iface, setTokenForSession_args args) throws org.apache.thrift.TException {
+ setTokenForSession_result result = new setTokenForSession_result();
+ iface.setTokenForSession(args.token);
+ return result;
+ }
+ }
+
public static class DeleteFtpUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, DeleteFtpUser_args> {
public DeleteFtpUser() {
super("DeleteFtpUser");
@@ -4021,6 +4098,7 @@ public class Server {
private static <I extends AsyncIface> Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
processMap.put("getFtpUser", new getFtpUser());
+ processMap.put("setTokenForSession", new setTokenForSession());
processMap.put("DeleteFtpUser", new DeleteFtpUser());
processMap.put("getPathOfImage", new getPathOfImage());
processMap.put("setInstitution", new setInstitution());
@@ -4118,6 +4196,56 @@ public class Server {
}
}
+ public static class setTokenForSession<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setTokenForSession_args, Void> {
+ public setTokenForSession() {
+ super("setTokenForSession");
+ }
+
+ public setTokenForSession_args getEmptyArgsInstance() {
+ return new setTokenForSession_args();
+ }
+
+ public AsyncMethodCallback<Void> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<Void>() {
+ public void onComplete(Void o) {
+ setTokenForSession_result result = new setTokenForSession_result();
+ try {
+ fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+ return;
+ } catch (Exception e) {
+ LOGGER.error("Exception writing to internal frame buffer", e);
+ }
+ fb.close();
+ }
+ public void onError(Exception e) {
+ byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+ org.apache.thrift.TBase msg;
+ setTokenForSession_result result = new setTokenForSession_result();
+ {
+ msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+ msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+ }
+ try {
+ fcall.sendResponse(fb,msg,msgType,seqid);
+ return;
+ } catch (Exception ex) {
+ LOGGER.error("Exception writing to internal frame buffer", ex);
+ }
+ fb.close();
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public void start(I iface, setTokenForSession_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException {
+ iface.setTokenForSession(args.token,resultHandler);
+ }
+ }
+
public static class DeleteFtpUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, DeleteFtpUser_args, Long> {
public DeleteFtpUser() {
super("DeleteFtpUser");
@@ -6931,6 +7059,606 @@ public class Server {
}
+ public static class setTokenForSession_args implements org.apache.thrift.TBase<setTokenForSession_args, setTokenForSession_args._Fields>, java.io.Serializable, Cloneable, Comparable<setTokenForSession_args> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setTokenForSession_args");
+
+ private static final org.apache.thrift.protocol.TField TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("token", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new setTokenForSession_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new setTokenForSession_argsTupleSchemeFactory());
+ }
+
+ public String token; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ TOKEN((short)1, "token");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // TOKEN
+ return TOKEN;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.TOKEN, new org.apache.thrift.meta_data.FieldMetaData("token", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setTokenForSession_args.class, metaDataMap);
+ }
+
+ public setTokenForSession_args() {
+ }
+
+ public setTokenForSession_args(
+ String token)
+ {
+ this();
+ this.token = token;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public setTokenForSession_args(setTokenForSession_args other) {
+ if (other.isSetToken()) {
+ this.token = other.token;
+ }
+ }
+
+ public setTokenForSession_args deepCopy() {
+ return new setTokenForSession_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.token = null;
+ }
+
+ public String getToken() {
+ return this.token;
+ }
+
+ public setTokenForSession_args setToken(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public void unsetToken() {
+ this.token = null;
+ }
+
+ /** Returns true if field token is set (has been assigned a value) and false otherwise */
+ public boolean isSetToken() {
+ return this.token != null;
+ }
+
+ public void setTokenIsSet(boolean value) {
+ if (!value) {
+ this.token = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case TOKEN:
+ if (value == null) {
+ unsetToken();
+ } else {
+ setToken((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case TOKEN:
+ return getToken();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case TOKEN:
+ return isSetToken();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof setTokenForSession_args)
+ return this.equals((setTokenForSession_args)that);
+ return false;
+ }
+
+ public boolean equals(setTokenForSession_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_token = true && this.isSetToken();
+ boolean that_present_token = true && that.isSetToken();
+ if (this_present_token || that_present_token) {
+ if (!(this_present_token && that_present_token))
+ return false;
+ if (!this.token.equals(that.token))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(setTokenForSession_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetToken()).compareTo(other.isSetToken());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetToken()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.token, other.token);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("setTokenForSession_args(");
+ boolean first = true;
+
+ sb.append("token:");
+ if (this.token == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.token);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class setTokenForSession_argsStandardSchemeFactory implements SchemeFactory {
+ public setTokenForSession_argsStandardScheme getScheme() {
+ return new setTokenForSession_argsStandardScheme();
+ }
+ }
+
+ private static class setTokenForSession_argsStandardScheme extends StandardScheme<setTokenForSession_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, setTokenForSession_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // TOKEN
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.token = iprot.readString();
+ struct.setTokenIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, setTokenForSession_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.token != null) {
+ oprot.writeFieldBegin(TOKEN_FIELD_DESC);
+ oprot.writeString(struct.token);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class setTokenForSession_argsTupleSchemeFactory implements SchemeFactory {
+ public setTokenForSession_argsTupleScheme getScheme() {
+ return new setTokenForSession_argsTupleScheme();
+ }
+ }
+
+ private static class setTokenForSession_argsTupleScheme extends TupleScheme<setTokenForSession_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, setTokenForSession_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetToken()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetToken()) {
+ oprot.writeString(struct.token);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, setTokenForSession_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.token = iprot.readString();
+ struct.setTokenIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class setTokenForSession_result implements org.apache.thrift.TBase<setTokenForSession_result, setTokenForSession_result._Fields>, java.io.Serializable, Cloneable, Comparable<setTokenForSession_result> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setTokenForSession_result");
+
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new setTokenForSession_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new setTokenForSession_resultTupleSchemeFactory());
+ }
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+;
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setTokenForSession_result.class, metaDataMap);
+ }
+
+ public setTokenForSession_result() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public setTokenForSession_result(setTokenForSession_result other) {
+ }
+
+ public setTokenForSession_result deepCopy() {
+ return new setTokenForSession_result(this);
+ }
+
+ @Override
+ public void clear() {
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof setTokenForSession_result)
+ return this.equals((setTokenForSession_result)that);
+ return false;
+ }
+
+ public boolean equals(setTokenForSession_result that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(setTokenForSession_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("setTokenForSession_result(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class setTokenForSession_resultStandardSchemeFactory implements SchemeFactory {
+ public setTokenForSession_resultStandardScheme getScheme() {
+ return new setTokenForSession_resultStandardScheme();
+ }
+ }
+
+ private static class setTokenForSession_resultStandardScheme extends StandardScheme<setTokenForSession_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, setTokenForSession_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, setTokenForSession_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class setTokenForSession_resultTupleSchemeFactory implements SchemeFactory {
+ public setTokenForSession_resultTupleScheme getScheme() {
+ return new setTokenForSession_resultTupleScheme();
+ }
+ }
+
+ private static class setTokenForSession_resultTupleScheme extends TupleScheme<setTokenForSession_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, setTokenForSession_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, setTokenForSession_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ }
+ }
+
+ }
+
public static class DeleteFtpUser_args implements org.apache.thrift.TBase<DeleteFtpUser_args, DeleteFtpUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<DeleteFtpUser_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DeleteFtpUser_args");
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;
-
}
+
diff --git a/dozentenmodulserver/thrift/server.thrift b/dozentenmodulserver/thrift/server.thrift
index 01714fb5..637e9be6 100644
--- a/dozentenmodulserver/thrift/server.thrift
+++ b/dozentenmodulserver/thrift/server.thrift
@@ -50,6 +50,7 @@ struct Person{
}
service Server{
User getFtpUser(),
+ void setTokenForSession(1: string token),
int DeleteFtpUser(1: string user),
string getPathOfImage(1: string image_id, 2: string version),
string setInstitution(1: string university),