From d8333a13c36b159c0b3de4f7ed189a6594056502 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 23 Feb 2023 15:41:10 +0100 Subject: [thrift] Add call for retrieving session data from access token --- .../openslx/bwlp/thrift/iface/MasterServer.java | 1158 +++++++++++++++++++- src/main/thrift/bwlp.thrift | 3 + 2 files changed, 1160 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java b/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java index fda3d60..e5cb8a5 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java @@ -6,7 +6,7 @@ */ package org.openslx.bwlp.thrift.iface; -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.17.0)", date = "2022-11-03") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.17.0)", date = "2023-02-23") @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) public class MasterServer { @@ -30,6 +30,8 @@ public class MasterServer { public void invalidateSession(java.lang.String sessionId) throws TInvalidTokenException, org.apache.thrift.TException; + public ClientSessionData getSessionFromAccessCode(java.lang.String accessCode) throws TNotFoundException, TAuthorizationException, org.apache.thrift.TException; + public UserInfo getUserFromToken(java.lang.String token) throws TInvalidTokenException, org.apache.thrift.TException; public boolean isServerAuthenticated(java.lang.String serverSessionId) throws org.apache.thrift.TException; @@ -82,6 +84,8 @@ public class MasterServer { public void invalidateSession(java.lang.String sessionId, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void getSessionFromAccessCode(java.lang.String accessCode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void getUserFromToken(java.lang.String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void isServerAuthenticated(java.lang.String serverSessionId, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -398,6 +402,36 @@ public class MasterServer { return; } + @Override + public ClientSessionData getSessionFromAccessCode(java.lang.String accessCode) throws TNotFoundException, TAuthorizationException, org.apache.thrift.TException + { + send_getSessionFromAccessCode(accessCode); + return recv_getSessionFromAccessCode(); + } + + public void send_getSessionFromAccessCode(java.lang.String accessCode) throws org.apache.thrift.TException + { + getSessionFromAccessCode_args args = new getSessionFromAccessCode_args(); + args.setAccessCode(accessCode); + sendBase("getSessionFromAccessCode", args); + } + + public ClientSessionData recv_getSessionFromAccessCode() throws TNotFoundException, TAuthorizationException, org.apache.thrift.TException + { + getSessionFromAccessCode_result result = new getSessionFromAccessCode_result(); + receiveBase(result, "getSessionFromAccessCode"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.notFound != null) { + throw result.notFound; + } + if (result.auth != null) { + throw result.auth; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getSessionFromAccessCode failed: unknown result"); + } + @Override public UserInfo getUserFromToken(java.lang.String token) throws TInvalidTokenException, org.apache.thrift.TException { @@ -1193,6 +1227,41 @@ public class MasterServer { } } + @Override + public void getSessionFromAccessCode(java.lang.String accessCode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getSessionFromAccessCode_call method_call = new getSessionFromAccessCode_call(accessCode, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getSessionFromAccessCode_call extends org.apache.thrift.async.TAsyncMethodCall { + private java.lang.String accessCode; + public getSessionFromAccessCode_call(java.lang.String accessCode, 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.accessCode = accessCode; + } + + @Override + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getSessionFromAccessCode", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getSessionFromAccessCode_args args = new getSessionFromAccessCode_args(); + args.setAccessCode(accessCode); + args.write(prot); + prot.writeMessageEnd(); + } + + @Override + public ClientSessionData getResult() throws TNotFoundException, TAuthorizationException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.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); + return (new Client(prot)).recv_getSessionFromAccessCode(); + } + } + @Override public void getUserFromToken(java.lang.String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); @@ -1767,6 +1836,7 @@ public class MasterServer { processMap.put("getImageDetails", new getImageDetails()); processMap.put("getUser", new getUser()); processMap.put("invalidateSession", new invalidateSession()); + processMap.put("getSessionFromAccessCode", new getSessionFromAccessCode()); processMap.put("getUserFromToken", new getUserFromToken()); processMap.put("isServerAuthenticated", new isServerAuthenticated()); processMap.put("startServerAuthentication", new startServerAuthentication()); @@ -2082,6 +2152,40 @@ public class MasterServer { } } + public static class getSessionFromAccessCode extends org.apache.thrift.ProcessFunction { + public getSessionFromAccessCode() { + super("getSessionFromAccessCode"); + } + + @Override + public getSessionFromAccessCode_args getEmptyArgsInstance() { + return new getSessionFromAccessCode_args(); + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + @Override + public getSessionFromAccessCode_result getResult(I iface, getSessionFromAccessCode_args args) throws org.apache.thrift.TException { + getSessionFromAccessCode_result result = new getSessionFromAccessCode_result(); + try { + result.success = iface.getSessionFromAccessCode(args.accessCode); + } catch (TNotFoundException notFound) { + result.notFound = notFound; + } catch (TAuthorizationException auth) { + result.auth = auth; + } + return result; + } + } + public static class getUserFromToken extends org.apache.thrift.ProcessFunction { public getUserFromToken() { super("getUserFromToken"); @@ -2601,6 +2705,7 @@ public class MasterServer { processMap.put("getImageDetails", new getImageDetails()); processMap.put("getUser", new getUser()); processMap.put("invalidateSession", new invalidateSession()); + processMap.put("getSessionFromAccessCode", new getSessionFromAccessCode()); processMap.put("getUserFromToken", new getUserFromToken()); processMap.put("isServerAuthenticated", new isServerAuthenticated()); processMap.put("startServerAuthentication", new startServerAuthentication()); @@ -3281,6 +3386,81 @@ public class MasterServer { } } + public static class getSessionFromAccessCode extends org.apache.thrift.AsyncProcessFunction { + public getSessionFromAccessCode() { + super("getSessionFromAccessCode"); + } + + @Override + public getSessionFromAccessCode_args getEmptyArgsInstance() { + return new getSessionFromAccessCode_args(); + } + + @Override + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + @Override + public void onComplete(ClientSessionData o) { + getSessionFromAccessCode_result result = new getSessionFromAccessCode_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + @Override + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + getSessionFromAccessCode_result result = new getSessionFromAccessCode_result(); + if (e instanceof TNotFoundException) { + result.notFound = (TNotFoundException) e; + result.setNotFoundIsSet(true); + msg = result; + } else if (e instanceof TAuthorizationException) { + result.auth = (TAuthorizationException) e; + result.setAuthIsSet(true); + msg = result; + } else if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + @Override + protected boolean isOneway() { + return false; + } + + @Override + public void start(I iface, getSessionFromAccessCode_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.getSessionFromAccessCode(args.accessCode,resultHandler); + } + } + public static class getUserFromToken extends org.apache.thrift.AsyncProcessFunction { public getUserFromToken() { super("getUserFromToken"); @@ -13432,6 +13612,982 @@ public class MasterServer { } } + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class getSessionFromAccessCode_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getSessionFromAccessCode_args"); + + private static final org.apache.thrift.protocol.TField ACCESS_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("accessCode", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getSessionFromAccessCode_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getSessionFromAccessCode_argsTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable java.lang.String accessCode; // 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 { + ACCESS_CODE((short)1, "accessCode"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ACCESS_CODE + return ACCESS_CODE; + 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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ACCESS_CODE, new org.apache.thrift.meta_data.FieldMetaData("accessCode", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getSessionFromAccessCode_args.class, metaDataMap); + } + + public getSessionFromAccessCode_args() { + } + + public getSessionFromAccessCode_args( + java.lang.String accessCode) + { + this(); + this.accessCode = accessCode; + } + + /** + * Performs a deep copy on other. + */ + public getSessionFromAccessCode_args(getSessionFromAccessCode_args other) { + if (other.isSetAccessCode()) { + this.accessCode = other.accessCode; + } + } + + @Override + public getSessionFromAccessCode_args deepCopy() { + return new getSessionFromAccessCode_args(this); + } + + @Override + public void clear() { + this.accessCode = null; + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getAccessCode() { + return this.accessCode; + } + + public getSessionFromAccessCode_args setAccessCode(@org.apache.thrift.annotation.Nullable java.lang.String accessCode) { + this.accessCode = accessCode; + return this; + } + + public void unsetAccessCode() { + this.accessCode = null; + } + + /** Returns true if field accessCode is set (has been assigned a value) and false otherwise */ + public boolean isSetAccessCode() { + return this.accessCode != null; + } + + public void setAccessCodeIsSet(boolean value) { + if (!value) { + this.accessCode = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case ACCESS_CODE: + if (value == null) { + unsetAccessCode(); + } else { + setAccessCode((java.lang.String)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case ACCESS_CODE: + return getAccessCode(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case ACCESS_CODE: + return isSetAccessCode(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getSessionFromAccessCode_args) + return this.equals((getSessionFromAccessCode_args)that); + return false; + } + + public boolean equals(getSessionFromAccessCode_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_accessCode = true && this.isSetAccessCode(); + boolean that_present_accessCode = true && that.isSetAccessCode(); + if (this_present_accessCode || that_present_accessCode) { + if (!(this_present_accessCode && that_present_accessCode)) + return false; + if (!this.accessCode.equals(that.accessCode)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetAccessCode()) ? 131071 : 524287); + if (isSetAccessCode()) + hashCode = hashCode * 8191 + accessCode.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getSessionFromAccessCode_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetAccessCode(), other.isSetAccessCode()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAccessCode()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.accessCode, other.accessCode); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getSessionFromAccessCode_args("); + boolean first = true; + + sb.append("accessCode:"); + if (this.accessCode == null) { + sb.append("null"); + } else { + sb.append(this.accessCode); + } + 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, java.lang.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 getSessionFromAccessCode_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getSessionFromAccessCode_argsStandardScheme getScheme() { + return new getSessionFromAccessCode_argsStandardScheme(); + } + } + + private static class getSessionFromAccessCode_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getSessionFromAccessCode_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: // ACCESS_CODE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.accessCode = iprot.readString(); + struct.setAccessCodeIsSet(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(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getSessionFromAccessCode_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.accessCode != null) { + oprot.writeFieldBegin(ACCESS_CODE_FIELD_DESC); + oprot.writeString(struct.accessCode); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getSessionFromAccessCode_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getSessionFromAccessCode_argsTupleScheme getScheme() { + return new getSessionFromAccessCode_argsTupleScheme(); + } + } + + private static class getSessionFromAccessCode_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getSessionFromAccessCode_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetAccessCode()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetAccessCode()) { + oprot.writeString(struct.accessCode); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getSessionFromAccessCode_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.accessCode = iprot.readString(); + struct.setAccessCodeIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) + public static class getSessionFromAccessCode_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getSessionFromAccessCode_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + private static final org.apache.thrift.protocol.TField NOT_FOUND_FIELD_DESC = new org.apache.thrift.protocol.TField("notFound", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField AUTH_FIELD_DESC = new org.apache.thrift.protocol.TField("auth", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getSessionFromAccessCode_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getSessionFromAccessCode_resultTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable ClientSessionData success; // required + public @org.apache.thrift.annotation.Nullable TNotFoundException notFound; // required + public @org.apache.thrift.annotation.Nullable TAuthorizationException auth; // 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 { + SUCCESS((short)0, "success"), + NOT_FOUND((short)1, "notFound"), + AUTH((short)2, "auth"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // NOT_FOUND + return NOT_FOUND; + case 2: // AUTH + return AUTH; + 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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + @Override + public short getThriftFieldId() { + return _thriftId; + } + + @Override + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ClientSessionData.class))); + tmpMap.put(_Fields.NOT_FOUND, new org.apache.thrift.meta_data.FieldMetaData("notFound", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TNotFoundException.class))); + tmpMap.put(_Fields.AUTH, new org.apache.thrift.meta_data.FieldMetaData("auth", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAuthorizationException.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getSessionFromAccessCode_result.class, metaDataMap); + } + + public getSessionFromAccessCode_result() { + } + + public getSessionFromAccessCode_result( + ClientSessionData success, + TNotFoundException notFound, + TAuthorizationException auth) + { + this(); + this.success = success; + this.notFound = notFound; + this.auth = auth; + } + + /** + * Performs a deep copy on other. + */ + public getSessionFromAccessCode_result(getSessionFromAccessCode_result other) { + if (other.isSetSuccess()) { + this.success = new ClientSessionData(other.success); + } + if (other.isSetNotFound()) { + this.notFound = new TNotFoundException(other.notFound); + } + if (other.isSetAuth()) { + this.auth = new TAuthorizationException(other.auth); + } + } + + @Override + public getSessionFromAccessCode_result deepCopy() { + return new getSessionFromAccessCode_result(this); + } + + @Override + public void clear() { + this.success = null; + this.notFound = null; + this.auth = null; + } + + @org.apache.thrift.annotation.Nullable + public ClientSessionData getSuccess() { + return this.success; + } + + public getSessionFromAccessCode_result setSuccess(@org.apache.thrift.annotation.Nullable ClientSessionData success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + @org.apache.thrift.annotation.Nullable + public TNotFoundException getNotFound() { + return this.notFound; + } + + public getSessionFromAccessCode_result setNotFound(@org.apache.thrift.annotation.Nullable TNotFoundException notFound) { + this.notFound = notFound; + return this; + } + + public void unsetNotFound() { + this.notFound = null; + } + + /** Returns true if field notFound is set (has been assigned a value) and false otherwise */ + public boolean isSetNotFound() { + return this.notFound != null; + } + + public void setNotFoundIsSet(boolean value) { + if (!value) { + this.notFound = null; + } + } + + @org.apache.thrift.annotation.Nullable + public TAuthorizationException getAuth() { + return this.auth; + } + + public getSessionFromAccessCode_result setAuth(@org.apache.thrift.annotation.Nullable TAuthorizationException auth) { + this.auth = auth; + return this; + } + + public void unsetAuth() { + this.auth = null; + } + + /** Returns true if field auth is set (has been assigned a value) and false otherwise */ + public boolean isSetAuth() { + return this.auth != null; + } + + public void setAuthIsSet(boolean value) { + if (!value) { + this.auth = null; + } + } + + @Override + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((ClientSessionData)value); + } + break; + + case NOT_FOUND: + if (value == null) { + unsetNotFound(); + } else { + setNotFound((TNotFoundException)value); + } + break; + + case AUTH: + if (value == null) { + unsetAuth(); + } else { + setAuth((TAuthorizationException)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + @Override + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case NOT_FOUND: + return getNotFound(); + + case AUTH: + return getAuth(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + @Override + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case NOT_FOUND: + return isSetNotFound(); + case AUTH: + return isSetAuth(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getSessionFromAccessCode_result) + return this.equals((getSessionFromAccessCode_result)that); + return false; + } + + public boolean equals(getSessionFromAccessCode_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_notFound = true && this.isSetNotFound(); + boolean that_present_notFound = true && that.isSetNotFound(); + if (this_present_notFound || that_present_notFound) { + if (!(this_present_notFound && that_present_notFound)) + return false; + if (!this.notFound.equals(that.notFound)) + return false; + } + + boolean this_present_auth = true && this.isSetAuth(); + boolean that_present_auth = true && that.isSetAuth(); + if (this_present_auth || that_present_auth) { + if (!(this_present_auth && that_present_auth)) + return false; + if (!this.auth.equals(that.auth)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + hashCode = hashCode * 8191 + ((isSetNotFound()) ? 131071 : 524287); + if (isSetNotFound()) + hashCode = hashCode * 8191 + notFound.hashCode(); + + hashCode = hashCode * 8191 + ((isSetAuth()) ? 131071 : 524287); + if (isSetAuth()) + hashCode = hashCode * 8191 + auth.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getSessionFromAccessCode_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetNotFound(), other.isSetNotFound()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNotFound()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.notFound, other.notFound); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetAuth(), other.isSetAuth()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAuth()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.auth, other.auth); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + @Override + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getSessionFromAccessCode_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("notFound:"); + if (this.notFound == null) { + sb.append("null"); + } else { + sb.append(this.notFound); + } + first = false; + if (!first) sb.append(", "); + sb.append("auth:"); + if (this.auth == null) { + sb.append("null"); + } else { + sb.append(this.auth); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + 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, java.lang.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 getSessionFromAccessCode_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getSessionFromAccessCode_resultStandardScheme getScheme() { + return new getSessionFromAccessCode_resultStandardScheme(); + } + } + + private static class getSessionFromAccessCode_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + @Override + public void read(org.apache.thrift.protocol.TProtocol iprot, getSessionFromAccessCode_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) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new ClientSessionData(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // NOT_FOUND + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.notFound = new TNotFoundException(); + struct.notFound.read(iprot); + struct.setNotFoundIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // AUTH + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.auth = new TAuthorizationException(); + struct.auth.read(iprot); + struct.setAuthIsSet(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(); + } + + @Override + public void write(org.apache.thrift.protocol.TProtocol oprot, getSessionFromAccessCode_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.notFound != null) { + oprot.writeFieldBegin(NOT_FOUND_FIELD_DESC); + struct.notFound.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.auth != null) { + oprot.writeFieldBegin(AUTH_FIELD_DESC); + struct.auth.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getSessionFromAccessCode_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + @Override + public getSessionFromAccessCode_resultTupleScheme getScheme() { + return new getSessionFromAccessCode_resultTupleScheme(); + } + } + + private static class getSessionFromAccessCode_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getSessionFromAccessCode_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetNotFound()) { + optionals.set(1); + } + if (struct.isSetAuth()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + if (struct.isSetNotFound()) { + struct.notFound.write(oprot); + } + if (struct.isSetAuth()) { + struct.auth.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getSessionFromAccessCode_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.success = new ClientSessionData(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.notFound = new TNotFoundException(); + struct.notFound.read(iprot); + struct.setNotFoundIsSet(true); + } + if (incoming.get(2)) { + struct.auth = new TAuthorizationException(); + struct.auth.read(iprot); + struct.setAuthIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) public static class getUserFromToken_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserFromToken_args"); diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 6ba7938..ad9f704 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -708,6 +708,9 @@ service MasterServer { void invalidateSession(1: Token sessionId) throws (1:TInvalidTokenException ex), + ClientSessionData getSessionFromAccessCode(1: string accessCode) + throws (1:TNotFoundException notFound, 2:TAuthorizationException auth), + /* * Server (Satellite) calls */ -- cgit v1.2.3-55-g7522