diff options
author | Simon Rettberg | 2015-07-15 17:26:44 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-15 17:26:44 +0200 |
commit | 87e36a604a6d475645d82aa5cdcec8b13bb37c95 (patch) | |
tree | e05e7ca3a5dfa750f6b6a709a29b58aa28af5807 | |
parent | Add classes for analyzing vm metadata files (diff) | |
download | master-sync-shared-87e36a604a6d475645d82aa5cdcec8b13bb37c95.tar.gz master-sync-shared-87e36a604a6d475645d82aa5cdcec8b13bb37c95.tar.xz master-sync-shared-87e36a604a6d475645d82aa5cdcec8b13bb37c95.zip |
Frickeled new thrift interface stuff
6 files changed, 263 insertions, 688 deletions
diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/AuthenticationError.java b/src/main/java/org/openslx/bwlp/thrift/iface/AuthenticationError.java deleted file mode 100644 index 9792787..0000000 --- a/src/main/java/org/openslx/bwlp/thrift/iface/AuthenticationError.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.openslx.bwlp.thrift.iface; - - -import java.util.Map; -import java.util.HashMap; -import org.apache.thrift.TEnum; - -public enum AuthenticationError implements org.apache.thrift.TEnum { - GENERIC_ERROR(0), - INVALID_CREDENTIALS(1), - ACCOUNT_SUSPENDED(2), - INVALID_ORGANIZATION(3), - INVALID_KEY(4), - CHALLENGE_FAILED(5), - BANNED_NETWORK(6); - - private final int value; - - private AuthenticationError(int value) { - this.value = value; - } - - /** - * Get the integer value of this enum value, as defined in the Thrift IDL. - */ - public int getValue() { - return value; - } - - /** - * Find a the enum type by its integer value, as defined in the Thrift IDL. - * @return null if the value is not found. - */ - public static AuthenticationError findByValue(int value) { - switch (value) { - case 0: - return GENERIC_ERROR; - case 1: - return INVALID_CREDENTIALS; - case 2: - return ACCOUNT_SUSPENDED; - case 3: - return INVALID_ORGANIZATION; - case 4: - return INVALID_KEY; - case 5: - return CHALLENGE_FAILED; - case 6: - return BANNED_NETWORK; - default: - return null; - } - } -} diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/AuthorizationError.java b/src/main/java/org/openslx/bwlp/thrift/iface/AuthorizationError.java index 022a697..c5100f1 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/AuthorizationError.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/AuthorizationError.java @@ -14,7 +14,15 @@ import org.apache.thrift.TEnum; public enum AuthorizationError implements org.apache.thrift.TEnum { GENERIC_ERROR(0), NOT_AUTHENTICATED(1), - NO_PERMISSION(2); + NO_PERMISSION(2), + ACCOUNT_SUSPENDED(3), + ORGANIZATION_SUSPENDED(4), + INVALID_CREDENTIALS(5), + INVALID_ORGANIZATION(6), + INVALID_KEY(7), + INVALID_TOKEN(8), + CHALLENGE_FAILED(9), + BANNED_NETWORK(10); private final int value; @@ -41,6 +49,22 @@ public enum AuthorizationError implements org.apache.thrift.TEnum { return NOT_AUTHENTICATED; case 2: return NO_PERMISSION; + case 3: + return ACCOUNT_SUSPENDED; + case 4: + return ORGANIZATION_SUSPENDED; + case 5: + return INVALID_CREDENTIALS; + case 6: + return INVALID_ORGANIZATION; + case 7: + return INVALID_KEY; + case 8: + return INVALID_TOKEN; + case 9: + return CHALLENGE_FAILED; + case 10: + return BANNED_NETWORK; default: return null; } 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 193a95e..052d3fb 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java @@ -50,9 +50,9 @@ public class MasterServer { public boolean isServerAuthenticated(String serverSessionId) throws org.apache.thrift.TException; - public ByteBuffer startServerAuthentication(String organizationId) throws TAuthenticationException, org.apache.thrift.TException; + public ByteBuffer startServerAuthentication(String organizationId) throws TAuthorizationException, org.apache.thrift.TException; - public ServerSessionData serverAuthenticate(String organizationId, ByteBuffer challengeResponse) throws TAuthenticationException, org.apache.thrift.TException; + public ServerSessionData serverAuthenticate(String organizationId, ByteBuffer challengeResponse) throws TAuthorizationException, org.apache.thrift.TException; public TransferInformation submitImage(String serverSessionId, ImagePublishData imageDescription, List<ByteBuffer> blockHashes) throws TAuthorizationException, TImageDataException, TTransferRejectedException, org.apache.thrift.TException; @@ -306,7 +306,7 @@ public class MasterServer { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isServerAuthenticated failed: unknown result"); } - public ByteBuffer startServerAuthentication(String organizationId) throws TAuthenticationException, org.apache.thrift.TException + public ByteBuffer startServerAuthentication(String organizationId) throws TAuthorizationException, org.apache.thrift.TException { send_startServerAuthentication(organizationId); return recv_startServerAuthentication(); @@ -319,7 +319,7 @@ public class MasterServer { sendBase("startServerAuthentication", args); } - public ByteBuffer recv_startServerAuthentication() throws TAuthenticationException, org.apache.thrift.TException + public ByteBuffer recv_startServerAuthentication() throws TAuthorizationException, org.apache.thrift.TException { startServerAuthentication_result result = new startServerAuthentication_result(); receiveBase(result, "startServerAuthentication"); @@ -332,7 +332,7 @@ public class MasterServer { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "startServerAuthentication failed: unknown result"); } - public ServerSessionData serverAuthenticate(String organizationId, ByteBuffer challengeResponse) throws TAuthenticationException, org.apache.thrift.TException + public ServerSessionData serverAuthenticate(String organizationId, ByteBuffer challengeResponse) throws TAuthorizationException, org.apache.thrift.TException { send_serverAuthenticate(organizationId, challengeResponse); return recv_serverAuthenticate(); @@ -346,7 +346,7 @@ public class MasterServer { sendBase("serverAuthenticate", args); } - public ServerSessionData recv_serverAuthenticate() throws TAuthenticationException, org.apache.thrift.TException + public ServerSessionData recv_serverAuthenticate() throws TAuthorizationException, org.apache.thrift.TException { serverAuthenticate_result result = new serverAuthenticate_result(); receiveBase(result, "serverAuthenticate"); @@ -815,7 +815,7 @@ public class MasterServer { prot.writeMessageEnd(); } - public ByteBuffer getResult() throws TAuthenticationException, org.apache.thrift.TException { + public ByteBuffer getResult() throws TAuthorizationException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } @@ -850,7 +850,7 @@ public class MasterServer { prot.writeMessageEnd(); } - public ServerSessionData getResult() throws TAuthenticationException, org.apache.thrift.TException { + public ServerSessionData getResult() throws TAuthorizationException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } @@ -1307,7 +1307,7 @@ public class MasterServer { startServerAuthentication_result result = new startServerAuthentication_result(); try { result.success = iface.startServerAuthentication(args.organizationId); - } catch (TAuthenticationException failure) { + } catch (TAuthorizationException failure) { result.failure = failure; } return result; @@ -1331,7 +1331,7 @@ public class MasterServer { serverAuthenticate_result result = new serverAuthenticate_result(); try { result.success = iface.serverAuthenticate(args.organizationId, args.challengeResponse); - } catch (TAuthenticationException failure) { + } catch (TAuthorizationException failure) { result.failure = failure; } return result; @@ -1942,8 +1942,8 @@ public class MasterServer { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TBase msg; startServerAuthentication_result result = new startServerAuthentication_result(); - if (e instanceof TAuthenticationException) { - result.failure = (TAuthenticationException) e; + if (e instanceof TAuthorizationException) { + result.failure = (TAuthorizationException) e; result.setFailureIsSet(true); msg = result; } @@ -1999,8 +1999,8 @@ public class MasterServer { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TBase msg; serverAuthenticate_result result = new serverAuthenticate_result(); - if (e instanceof TAuthenticationException) { - result.failure = (TAuthenticationException) e; + if (e instanceof TAuthorizationException) { + result.failure = (TAuthorizationException) e; result.setFailureIsSet(true); msg = result; } @@ -8763,7 +8763,7 @@ public class MasterServer { } public ByteBuffer success; // required - public TAuthenticationException failure; // required + public TAuthorizationException failure; // 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 { @@ -8843,7 +8843,7 @@ public class MasterServer { public startServerAuthentication_result( ByteBuffer success, - TAuthenticationException failure) + TAuthorizationException failure) { this(); this.success = success; @@ -8859,7 +8859,7 @@ public class MasterServer { ; } if (other.isSetFailure()) { - this.failure = new TAuthenticationException(other.failure); + this.failure = new TAuthorizationException(other.failure); } } @@ -8907,11 +8907,11 @@ public class MasterServer { } } - public TAuthenticationException getFailure() { + public TAuthorizationException getFailure() { return this.failure; } - public startServerAuthentication_result setFailure(TAuthenticationException failure) { + public startServerAuthentication_result setFailure(TAuthorizationException failure) { this.failure = failure; return this; } @@ -8945,7 +8945,7 @@ public class MasterServer { if (value == null) { unsetFailure(); } else { - setFailure((TAuthenticationException)value); + setFailure((TAuthorizationException)value); } break; @@ -9134,7 +9134,7 @@ public class MasterServer { break; case 1: // FAILURE if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.failure = new TAuthenticationException(); + struct.failure = new TAuthorizationException(); struct.failure.read(iprot); struct.setFailureIsSet(true); } else { @@ -9208,7 +9208,7 @@ public class MasterServer { struct.setSuccessIsSet(true); } if (incoming.get(1)) { - struct.failure = new TAuthenticationException(); + struct.failure = new TAuthorizationException(); struct.failure.read(iprot); struct.setFailureIsSet(true); } @@ -9695,7 +9695,7 @@ public class MasterServer { } public ServerSessionData success; // required - public TAuthenticationException failure; // required + public TAuthorizationException failure; // 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 { @@ -9775,7 +9775,7 @@ public class MasterServer { public serverAuthenticate_result( ServerSessionData success, - TAuthenticationException failure) + TAuthorizationException failure) { this(); this.success = success; @@ -9790,7 +9790,7 @@ public class MasterServer { this.success = new ServerSessionData(other.success); } if (other.isSetFailure()) { - this.failure = new TAuthenticationException(other.failure); + this.failure = new TAuthorizationException(other.failure); } } @@ -9828,11 +9828,11 @@ public class MasterServer { } } - public TAuthenticationException getFailure() { + public TAuthorizationException getFailure() { return this.failure; } - public serverAuthenticate_result setFailure(TAuthenticationException failure) { + public serverAuthenticate_result setFailure(TAuthorizationException failure) { this.failure = failure; return this; } @@ -9866,7 +9866,7 @@ public class MasterServer { if (value == null) { unsetFailure(); } else { - setFailure((TAuthenticationException)value); + setFailure((TAuthorizationException)value); } break; @@ -10059,7 +10059,7 @@ public class MasterServer { break; case 1: // FAILURE if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.failure = new TAuthenticationException(); + struct.failure = new TAuthorizationException(); struct.failure.read(iprot); struct.setFailureIsSet(true); } else { @@ -10134,7 +10134,7 @@ public class MasterServer { struct.setSuccessIsSet(true); } if (incoming.get(1)) { - struct.failure = new TAuthenticationException(); + struct.failure = new TAuthorizationException(); struct.failure.read(iprot); struct.setFailureIsSet(true); } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java index f15b0ad..aab3cb8 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteServer.java @@ -50,7 +50,7 @@ public class SatelliteServer { public void cancelDownload(String downloadToken) throws org.apache.thrift.TException; - public boolean isAuthenticated(String userToken) throws org.apache.thrift.TException; + public void isAuthenticated(String userToken) throws TAuthorizationException, TInternalServerError, org.apache.thrift.TException; public void invalidateSession(String userToken) throws org.apache.thrift.TException; @@ -351,10 +351,10 @@ public class SatelliteServer { return; } - public boolean isAuthenticated(String userToken) throws org.apache.thrift.TException + public void isAuthenticated(String userToken) throws TAuthorizationException, TInternalServerError, org.apache.thrift.TException { send_isAuthenticated(userToken); - return recv_isAuthenticated(); + recv_isAuthenticated(); } public void send_isAuthenticated(String userToken) throws org.apache.thrift.TException @@ -364,14 +364,17 @@ public class SatelliteServer { sendBase("isAuthenticated", args); } - public boolean recv_isAuthenticated() throws org.apache.thrift.TException + public void recv_isAuthenticated() throws TAuthorizationException, TInternalServerError, org.apache.thrift.TException { isAuthenticated_result result = new isAuthenticated_result(); receiveBase(result, "isAuthenticated"); - if (result.isSetSuccess()) { - return result.success; + if (result.authError != null) { + throw result.authError; } - throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isAuthenticated failed: unknown result"); + if (result.serverError != null) { + throw result.serverError; + } + return; } public void invalidateSession(String userToken) throws org.apache.thrift.TException @@ -1299,13 +1302,13 @@ public class SatelliteServer { prot.writeMessageEnd(); } - public boolean getResult() throws org.apache.thrift.TException { + public void getResult() throws TAuthorizationException, TInternalServerError, 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); - return (new Client(prot)).recv_isAuthenticated(); + (new Client(prot)).recv_isAuthenticated(); } } @@ -2299,8 +2302,13 @@ public class SatelliteServer { public isAuthenticated_result getResult(I iface, isAuthenticated_args args) throws org.apache.thrift.TException { isAuthenticated_result result = new isAuthenticated_result(); - result.success = iface.isAuthenticated(args.userToken); - result.setSuccessIsSet(true); + try { + iface.isAuthenticated(args.userToken); + } catch (TAuthorizationException authError) { + result.authError = authError; + } catch (TInternalServerError serverError) { + result.serverError = serverError; + } return result; } } @@ -3311,7 +3319,7 @@ public class SatelliteServer { } } - public static class isAuthenticated<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isAuthenticated_args, Boolean> { + public static class isAuthenticated<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isAuthenticated_args, Void> { public isAuthenticated() { super("isAuthenticated"); } @@ -3320,13 +3328,11 @@ public class SatelliteServer { return new isAuthenticated_args(); } - public AsyncMethodCallback<Boolean> getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + public AsyncMethodCallback<Void> getResultHandler(final AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback<Boolean>() { - public void onComplete(Boolean o) { + return new AsyncMethodCallback<Void>() { + public void onComplete(Void o) { isAuthenticated_result result = new isAuthenticated_result(); - result.success = o; - result.setSuccessIsSet(true); try { fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); return; @@ -3339,6 +3345,17 @@ public class SatelliteServer { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TBase msg; isAuthenticated_result result = new isAuthenticated_result(); + if (e instanceof TAuthorizationException) { + result.authError = (TAuthorizationException) e; + result.setAuthErrorIsSet(true); + msg = result; + } + else if (e instanceof TInternalServerError) { + result.serverError = (TInternalServerError) e; + result.setServerErrorIsSet(true); + msg = result; + } + else { 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()); @@ -3358,7 +3375,7 @@ public class SatelliteServer { return false; } - public void start(I iface, isAuthenticated_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException { + public void start(I iface, isAuthenticated_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException { iface.isAuthenticated(args.userToken,resultHandler); } } @@ -10506,7 +10523,8 @@ public class SatelliteServer { public static class isAuthenticated_result implements org.apache.thrift.TBase<isAuthenticated_result, isAuthenticated_result._Fields>, java.io.Serializable, Cloneable, Comparable<isAuthenticated_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isAuthenticated_result"); - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); + private static final org.apache.thrift.protocol.TField AUTH_ERROR_FIELD_DESC = new org.apache.thrift.protocol.TField("authError", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField SERVER_ERROR_FIELD_DESC = new org.apache.thrift.protocol.TField("serverError", org.apache.thrift.protocol.TType.STRUCT, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -10514,11 +10532,13 @@ public class SatelliteServer { schemes.put(TupleScheme.class, new isAuthenticated_resultTupleSchemeFactory()); } - public boolean success; // required + public TAuthorizationException authError; // required + public TInternalServerError serverError; // 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"); + AUTH_ERROR((short)1, "authError"), + SERVER_ERROR((short)2, "serverError"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -10533,8 +10553,10 @@ public class SatelliteServer { */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; + case 1: // AUTH_ERROR + return AUTH_ERROR; + case 2: // SERVER_ERROR + return SERVER_ERROR; default: return null; } @@ -10575,13 +10597,13 @@ public class SatelliteServer { } // isset id assignments - private static final int __SUCCESS_ISSET_ID = 0; - private byte __isset_bitfield = 0; 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.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.AUTH_ERROR, new org.apache.thrift.meta_data.FieldMetaData("authError", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.SERVER_ERROR, new org.apache.thrift.meta_data.FieldMetaData("serverError", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isAuthenticated_result.class, metaDataMap); } @@ -10590,19 +10612,24 @@ public class SatelliteServer { } public isAuthenticated_result( - boolean success) + TAuthorizationException authError, + TInternalServerError serverError) { this(); - this.success = success; - setSuccessIsSet(true); + this.authError = authError; + this.serverError = serverError; } /** * Performs a deep copy on <i>other</i>. */ public isAuthenticated_result(isAuthenticated_result other) { - __isset_bitfield = other.__isset_bitfield; - this.success = other.success; + if (other.isSetAuthError()) { + this.authError = new TAuthorizationException(other.authError); + } + if (other.isSetServerError()) { + this.serverError = new TInternalServerError(other.serverError); + } } public isAuthenticated_result deepCopy() { @@ -10611,40 +10638,73 @@ public class SatelliteServer { @Override public void clear() { - setSuccessIsSet(false); - this.success = false; + this.authError = null; + this.serverError = null; } - public boolean isSuccess() { - return this.success; + public TAuthorizationException getAuthError() { + return this.authError; } - public isAuthenticated_result setSuccess(boolean success) { - this.success = success; - setSuccessIsSet(true); + public isAuthenticated_result setAuthError(TAuthorizationException authError) { + this.authError = authError; return this; } - public void unsetSuccess() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + public void unsetAuthError() { + this.authError = null; } - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + /** Returns true if field authError is set (has been assigned a value) and false otherwise */ + public boolean isSetAuthError() { + return this.authError != null; } - public void setSuccessIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + public void setAuthErrorIsSet(boolean value) { + if (!value) { + this.authError = null; + } + } + + public TInternalServerError getServerError() { + return this.serverError; + } + + public isAuthenticated_result setServerError(TInternalServerError serverError) { + this.serverError = serverError; + return this; + } + + public void unsetServerError() { + this.serverError = null; + } + + /** Returns true if field serverError is set (has been assigned a value) and false otherwise */ + public boolean isSetServerError() { + return this.serverError != null; + } + + public void setServerErrorIsSet(boolean value) { + if (!value) { + this.serverError = null; + } } public void setFieldValue(_Fields field, Object value) { switch (field) { - case SUCCESS: + case AUTH_ERROR: if (value == null) { - unsetSuccess(); + unsetAuthError(); } else { - setSuccess((Boolean)value); + setAuthError((TAuthorizationException)value); + } + break; + + case SERVER_ERROR: + if (value == null) { + unsetServerError(); + } else { + setServerError((TInternalServerError)value); } break; @@ -10653,8 +10713,11 @@ public class SatelliteServer { public Object getFieldValue(_Fields field) { switch (field) { - case SUCCESS: - return Boolean.valueOf(isSuccess()); + case AUTH_ERROR: + return getAuthError(); + + case SERVER_ERROR: + return getServerError(); } throw new IllegalStateException(); @@ -10667,8 +10730,10 @@ public class SatelliteServer { } switch (field) { - case SUCCESS: - return isSetSuccess(); + case AUTH_ERROR: + return isSetAuthError(); + case SERVER_ERROR: + return isSetServerError(); } throw new IllegalStateException(); } @@ -10686,12 +10751,21 @@ public class SatelliteServer { if (that == null) return false; - boolean this_present_success = true; - boolean that_present_success = true; - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) + boolean this_present_authError = true && this.isSetAuthError(); + boolean that_present_authError = true && that.isSetAuthError(); + if (this_present_authError || that_present_authError) { + if (!(this_present_authError && that_present_authError)) return false; - if (this.success != that.success) + if (!this.authError.equals(that.authError)) + return false; + } + + boolean this_present_serverError = true && this.isSetServerError(); + boolean that_present_serverError = true && that.isSetServerError(); + if (this_present_serverError || that_present_serverError) { + if (!(this_present_serverError && that_present_serverError)) + return false; + if (!this.serverError.equals(that.serverError)) return false; } @@ -10711,12 +10785,22 @@ public class SatelliteServer { int lastComparison = 0; - lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + lastComparison = Boolean.valueOf(isSetAuthError()).compareTo(other.isSetAuthError()); if (lastComparison != 0) { return lastComparison; } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (isSetAuthError()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authError, other.authError); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetServerError()).compareTo(other.isSetServerError()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServerError()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverError, other.serverError); if (lastComparison != 0) { return lastComparison; } @@ -10741,8 +10825,20 @@ public class SatelliteServer { StringBuilder sb = new StringBuilder("isAuthenticated_result("); boolean first = true; - sb.append("success:"); - sb.append(this.success); + sb.append("authError:"); + if (this.authError == null) { + sb.append("null"); + } else { + sb.append(this.authError); + } + first = false; + if (!first) sb.append(", "); + sb.append("serverError:"); + if (this.serverError == null) { + sb.append("null"); + } else { + sb.append(this.serverError); + } first = false; sb.append(")"); return sb.toString(); @@ -10763,8 +10859,6 @@ public class SatelliteServer { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; 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); @@ -10789,10 +10883,20 @@ public class SatelliteServer { break; } switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.success = iprot.readBool(); - struct.setSuccessIsSet(true); + case 1: // AUTH_ERROR + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.authError = new TAuthorizationException(); + struct.authError.read(iprot); + struct.setAuthErrorIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SERVER_ERROR + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.serverError = new TInternalServerError(); + struct.serverError.read(iprot); + struct.setServerErrorIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -10812,9 +10916,14 @@ public class SatelliteServer { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); - if (struct.isSetSuccess()) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - oprot.writeBool(struct.success); + if (struct.authError != null) { + oprot.writeFieldBegin(AUTH_ERROR_FIELD_DESC); + struct.authError.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.serverError != null) { + oprot.writeFieldBegin(SERVER_ERROR_FIELD_DESC); + struct.serverError.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); @@ -10835,22 +10944,34 @@ public class SatelliteServer { public void write(org.apache.thrift.protocol.TProtocol prot, isAuthenticated_result struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); - if (struct.isSetSuccess()) { + if (struct.isSetAuthError()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); - if (struct.isSetSuccess()) { - oprot.writeBool(struct.success); + if (struct.isSetServerError()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetAuthError()) { + struct.authError.write(oprot); + } + if (struct.isSetServerError()) { + struct.serverError.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, isAuthenticated_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { - struct.success = iprot.readBool(); - struct.setSuccessIsSet(true); + struct.authError = new TAuthorizationException(); + struct.authError.read(iprot); + struct.setAuthErrorIsSet(true); + } + if (incoming.get(1)) { + struct.serverError = new TInternalServerError(); + struct.serverError.read(iprot); + struct.setServerErrorIsSet(true); } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/TAuthenticationException.java b/src/main/java/org/openslx/bwlp/thrift/iface/TAuthenticationException.java deleted file mode 100644 index b5b5078..0000000 --- a/src/main/java/org/openslx/bwlp/thrift/iface/TAuthenticationException.java +++ /dev/null @@ -1,504 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.openslx.bwlp.thrift.iface; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TAuthenticationException extends TException implements org.apache.thrift.TBase<TAuthenticationException, TAuthenticationException._Fields>, java.io.Serializable, Cloneable, Comparable<TAuthenticationException> { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAuthenticationException"); - - private static final org.apache.thrift.protocol.TField NUMBER_FIELD_DESC = new org.apache.thrift.protocol.TField("number", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)2); - - private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new TAuthenticationExceptionStandardSchemeFactory()); - schemes.put(TupleScheme.class, new TAuthenticationExceptionTupleSchemeFactory()); - } - - /** - * - * @see AuthenticationError - */ - public AuthenticationError number; // required - public String message; // 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 { - /** - * - * @see AuthenticationError - */ - NUMBER((short)1, "number"), - MESSAGE((short)2, "message"); - - 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: // NUMBER - return NUMBER; - case 2: // MESSAGE - return MESSAGE; - 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.NUMBER, new org.apache.thrift.meta_data.FieldMetaData("number", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, AuthenticationError.class))); - tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", 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(TAuthenticationException.class, metaDataMap); - } - - public TAuthenticationException() { - } - - public TAuthenticationException( - AuthenticationError number, - String message) - { - this(); - this.number = number; - this.message = message; - } - - /** - * Performs a deep copy on <i>other</i>. - */ - public TAuthenticationException(TAuthenticationException other) { - if (other.isSetNumber()) { - this.number = other.number; - } - if (other.isSetMessage()) { - this.message = other.message; - } - } - - public TAuthenticationException deepCopy() { - return new TAuthenticationException(this); - } - - @Override - public void clear() { - this.number = null; - this.message = null; - } - - /** - * - * @see AuthenticationError - */ - public AuthenticationError getNumber() { - return this.number; - } - - /** - * - * @see AuthenticationError - */ - public TAuthenticationException setNumber(AuthenticationError number) { - this.number = number; - return this; - } - - public void unsetNumber() { - this.number = null; - } - - /** Returns true if field number is set (has been assigned a value) and false otherwise */ - public boolean isSetNumber() { - return this.number != null; - } - - public void setNumberIsSet(boolean value) { - if (!value) { - this.number = null; - } - } - - public String getMessage() { - return this.message; - } - - public TAuthenticationException setMessage(String message) { - this.message = message; - return this; - } - - public void unsetMessage() { - this.message = null; - } - - /** Returns true if field message is set (has been assigned a value) and false otherwise */ - public boolean isSetMessage() { - return this.message != null; - } - - public void setMessageIsSet(boolean value) { - if (!value) { - this.message = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case NUMBER: - if (value == null) { - unsetNumber(); - } else { - setNumber((AuthenticationError)value); - } - break; - - case MESSAGE: - if (value == null) { - unsetMessage(); - } else { - setMessage((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case NUMBER: - return getNumber(); - - case MESSAGE: - return getMessage(); - - } - 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 NUMBER: - return isSetNumber(); - case MESSAGE: - return isSetMessage(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof TAuthenticationException) - return this.equals((TAuthenticationException)that); - return false; - } - - public boolean equals(TAuthenticationException that) { - if (that == null) - return false; - - boolean this_present_number = true && this.isSetNumber(); - boolean that_present_number = true && that.isSetNumber(); - if (this_present_number || that_present_number) { - if (!(this_present_number && that_present_number)) - return false; - if (!this.number.equals(that.number)) - return false; - } - - boolean this_present_message = true && this.isSetMessage(); - boolean that_present_message = true && that.isSetMessage(); - if (this_present_message || that_present_message) { - if (!(this_present_message && that_present_message)) - return false; - if (!this.message.equals(that.message)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(TAuthenticationException other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetNumber()).compareTo(other.isSetNumber()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetNumber()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.number, other.number); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetMessage()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message); - 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("TAuthenticationException("); - boolean first = true; - - sb.append("number:"); - if (this.number == null) { - sb.append("null"); - } else { - sb.append(this.number); - } - first = false; - if (!first) sb.append(", "); - sb.append("message:"); - if (this.message == null) { - sb.append("null"); - } else { - sb.append(this.message); - } - 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 TAuthenticationExceptionStandardSchemeFactory implements SchemeFactory { - public TAuthenticationExceptionStandardScheme getScheme() { - return new TAuthenticationExceptionStandardScheme(); - } - } - - private static class TAuthenticationExceptionStandardScheme extends StandardScheme<TAuthenticationException> { - - public void read(org.apache.thrift.protocol.TProtocol iprot, TAuthenticationException 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: // NUMBER - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.number = AuthenticationError.findByValue(iprot.readI32()); - struct.setNumberIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // MESSAGE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.message = iprot.readString(); - struct.setMessageIsSet(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, TAuthenticationException struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.number != null) { - oprot.writeFieldBegin(NUMBER_FIELD_DESC); - oprot.writeI32(struct.number.getValue()); - oprot.writeFieldEnd(); - } - if (struct.message != null) { - oprot.writeFieldBegin(MESSAGE_FIELD_DESC); - oprot.writeString(struct.message); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class TAuthenticationExceptionTupleSchemeFactory implements SchemeFactory { - public TAuthenticationExceptionTupleScheme getScheme() { - return new TAuthenticationExceptionTupleScheme(); - } - } - - private static class TAuthenticationExceptionTupleScheme extends TupleScheme<TAuthenticationException> { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, TAuthenticationException struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetNumber()) { - optionals.set(0); - } - if (struct.isSetMessage()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetNumber()) { - oprot.writeI32(struct.number.getValue()); - } - if (struct.isSetMessage()) { - oprot.writeString(struct.message); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, TAuthenticationException struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.number = AuthenticationError.findByValue(iprot.readI32()); - struct.setNumberIsSet(true); - } - if (incoming.get(1)) { - struct.message = iprot.readString(); - struct.setMessageIsSet(true); - } - } - } - -} - diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 0f4217a..b135094 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -20,15 +20,13 @@ typedef i64 UnixTimestamp enum AuthorizationError { GENERIC_ERROR, NOT_AUTHENTICATED, - NO_PERMISSION -} - -enum AuthenticationError { - GENERIC_ERROR, - INVALID_CREDENTIALS, + NO_PERMISSION, ACCOUNT_SUSPENDED, + ORGANIZATION_SUSPENDED, + INVALID_CREDENTIALS, INVALID_ORGANIZATION, INVALID_KEY, + INVALID_TOKEN, CHALLENGE_FAILED, BANNED_NETWORK } @@ -298,11 +296,6 @@ exception TAuthorizationException { 2: string message } -exception TAuthenticationException { - 1: AuthenticationError number, - 2: string message -} - exception TInvalidTokenException { } @@ -338,7 +331,8 @@ service SatelliteServer { void cancelDownload(1: string downloadToken), // Authentication - bool isAuthenticated(1: Token userToken), + void isAuthenticated(1: Token userToken) + throws (1:TAuthorizationException authError, 2:TInternalServerError serverError), void invalidateSession(1: Token userToken), // find a user in a given organization by a search term @@ -444,10 +438,10 @@ service MasterServer { bool isServerAuthenticated(1:Token serverSessionId), // Start authentication of server for given organization binary startServerAuthentication(1:string organizationId) - throws (1: TAuthenticationException failure), + throws (1: TAuthorizationException failure), // Reply to master server authentication challenge ServerSessionData serverAuthenticate(1:string organizationId, 2:binary challengeResponse) - throws (1:TAuthenticationException failure), + throws (1:TAuthorizationException failure), // Request upload of an image to the master server TransferInformation submitImage(1:Token serverSessionId, 2:ImagePublishData imageDescription, 3:list<binary> blockHashes) throws (1:TAuthorizationException failure, 2: TImageDataException failure2, 3: TTransferRejectedException failure3), |