Repository: incubator-sentry Updated Branches: refs/heads/master 58f5f529f -> 2fb35eb9c
SENTRY-415: Add API to Sentry Service that allows clients to read the service's config values. (Mike Yoder via Prasad Mujumdar) Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/2fb35eb9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/2fb35eb9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/2fb35eb9 Branch: refs/heads/master Commit: 2fb35eb9c51831eb6d54d25199b21cd4ebf15a2b Parents: 58f5f52 Author: Prasad Mujumdar <[email protected]> Authored: Mon Oct 27 14:30:15 2014 -0700 Committer: Prasad Mujumdar <[email protected]> Committed: Mon Oct 27 14:30:15 2014 -0700 ---------------------------------------------------------------------- .../db/service/thrift/SentryPolicyService.java | 806 +++++++++++++++++++ .../thrift/TSentryConfigValueRequest.java | 596 ++++++++++++++ .../thrift/TSentryConfigValueResponse.java | 500 ++++++++++++ .../thrift/SentryPolicyServiceClient.java | 28 +- .../thrift/SentryPolicyStoreProcessor.java | 31 + .../main/resources/sentry_policy_service.thrift | 13 + .../thrift/TestSentryServiceIntegration.java | 59 ++ 7 files changed, 2032 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java index d112871..c47f64a 100644 --- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java +++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java @@ -59,6 +59,8 @@ public class SentryPolicyService { public TListSentryPrivilegesByAuthResponse list_sentry_privileges_by_authorizable(TListSentryPrivilegesByAuthRequest request) throws org.apache.thrift.TException; + public TSentryConfigValueResponse get_sentry_config_value(TSentryConfigValueRequest request) throws org.apache.thrift.TException; + } public interface AsyncIface { @@ -87,6 +89,8 @@ public class SentryPolicyService { public void list_sentry_privileges_by_authorizable(TListSentryPrivilegesByAuthRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_privileges_by_authorizable_call> resultHandler) throws org.apache.thrift.TException; + public void get_sentry_config_value(TSentryConfigValueRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.get_sentry_config_value_call> resultHandler) throws org.apache.thrift.TException; + } public static class Client extends org.apache.thrift.TServiceClient implements Iface { @@ -385,6 +389,29 @@ public class SentryPolicyService { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_sentry_privileges_by_authorizable failed: unknown result"); } + public TSentryConfigValueResponse get_sentry_config_value(TSentryConfigValueRequest request) throws org.apache.thrift.TException + { + send_get_sentry_config_value(request); + return recv_get_sentry_config_value(); + } + + public void send_get_sentry_config_value(TSentryConfigValueRequest request) throws org.apache.thrift.TException + { + get_sentry_config_value_args args = new get_sentry_config_value_args(); + args.setRequest(request); + sendBase("get_sentry_config_value", args); + } + + public TSentryConfigValueResponse recv_get_sentry_config_value() throws org.apache.thrift.TException + { + get_sentry_config_value_result result = new get_sentry_config_value_result(); + receiveBase(result, "get_sentry_config_value"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "get_sentry_config_value failed: unknown result"); + } + } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> { @@ -787,6 +814,38 @@ public class SentryPolicyService { } } + public void get_sentry_config_value(TSentryConfigValueRequest request, org.apache.thrift.async.AsyncMethodCallback<get_sentry_config_value_call> resultHandler) throws org.apache.thrift.TException { + checkReady(); + get_sentry_config_value_call method_call = new get_sentry_config_value_call(request, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class get_sentry_config_value_call extends org.apache.thrift.async.TAsyncMethodCall { + private TSentryConfigValueRequest request; + public get_sentry_config_value_call(TSentryConfigValueRequest request, org.apache.thrift.async.AsyncMethodCallback<get_sentry_config_value_call> 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.request = request; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("get_sentry_config_value", org.apache.thrift.protocol.TMessageType.CALL, 0)); + get_sentry_config_value_args args = new get_sentry_config_value_args(); + args.setRequest(request); + args.write(prot); + prot.writeMessageEnd(); + } + + public TSentryConfigValueResponse 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); + return (new Client(prot)).recv_get_sentry_config_value(); + } + } + } public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor { @@ -812,6 +871,7 @@ public class SentryPolicyService { processMap.put("drop_sentry_privilege", new drop_sentry_privilege()); processMap.put("rename_sentry_privilege", new rename_sentry_privilege()); processMap.put("list_sentry_privileges_by_authorizable", new list_sentry_privileges_by_authorizable()); + processMap.put("get_sentry_config_value", new get_sentry_config_value()); return processMap; } @@ -1055,6 +1115,26 @@ public class SentryPolicyService { } } + public static class get_sentry_config_value<I extends Iface> extends org.apache.thrift.ProcessFunction<I, get_sentry_config_value_args> { + public get_sentry_config_value() { + super("get_sentry_config_value"); + } + + public get_sentry_config_value_args getEmptyArgsInstance() { + return new get_sentry_config_value_args(); + } + + protected boolean isOneway() { + return false; + } + + public get_sentry_config_value_result getResult(I iface, get_sentry_config_value_args args) throws org.apache.thrift.TException { + get_sentry_config_value_result result = new get_sentry_config_value_result(); + result.success = iface.get_sentry_config_value(args.request); + return result; + } + } + } public static class create_sentry_role_args implements org.apache.thrift.TBase<create_sentry_role_args, create_sentry_role_args._Fields>, java.io.Serializable, Cloneable { @@ -9769,4 +9849,730 @@ public class SentryPolicyService { } + public static class get_sentry_config_value_args implements org.apache.thrift.TBase<get_sentry_config_value_args, get_sentry_config_value_args._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("get_sentry_config_value_args"); + + private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new get_sentry_config_value_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new get_sentry_config_value_argsTupleSchemeFactory()); + } + + private TSentryConfigValueRequest request; // 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 { + REQUEST((short)1, "request"); + + 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: // REQUEST + return REQUEST; + 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.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryConfigValueRequest.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_sentry_config_value_args.class, metaDataMap); + } + + public get_sentry_config_value_args() { + } + + public get_sentry_config_value_args( + TSentryConfigValueRequest request) + { + this(); + this.request = request; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public get_sentry_config_value_args(get_sentry_config_value_args other) { + if (other.isSetRequest()) { + this.request = new TSentryConfigValueRequest(other.request); + } + } + + public get_sentry_config_value_args deepCopy() { + return new get_sentry_config_value_args(this); + } + + @Override + public void clear() { + this.request = null; + } + + public TSentryConfigValueRequest getRequest() { + return this.request; + } + + public void setRequest(TSentryConfigValueRequest request) { + this.request = request; + } + + public void unsetRequest() { + this.request = null; + } + + /** Returns true if field request is set (has been assigned a value) and false otherwise */ + public boolean isSetRequest() { + return this.request != null; + } + + public void setRequestIsSet(boolean value) { + if (!value) { + this.request = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case REQUEST: + if (value == null) { + unsetRequest(); + } else { + setRequest((TSentryConfigValueRequest)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case REQUEST: + return getRequest(); + + } + 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 REQUEST: + return isSetRequest(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_sentry_config_value_args) + return this.equals((get_sentry_config_value_args)that); + return false; + } + + public boolean equals(get_sentry_config_value_args that) { + if (that == null) + return false; + + boolean this_present_request = true && this.isSetRequest(); + boolean that_present_request = true && that.isSetRequest(); + if (this_present_request || that_present_request) { + if (!(this_present_request && that_present_request)) + return false; + if (!this.request.equals(that.request)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_request = true && (isSetRequest()); + builder.append(present_request); + if (present_request) + builder.append(request); + + return builder.toHashCode(); + } + + public int compareTo(get_sentry_config_value_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_sentry_config_value_args typedOther = (get_sentry_config_value_args)other; + + lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRequest()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request); + 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("get_sentry_config_value_args("); + boolean first = true; + + sb.append("request:"); + if (this.request == null) { + sb.append("null"); + } else { + sb.append(this.request); + } + 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 (request != null) { + request.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, 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 get_sentry_config_value_argsStandardSchemeFactory implements SchemeFactory { + public get_sentry_config_value_argsStandardScheme getScheme() { + return new get_sentry_config_value_argsStandardScheme(); + } + } + + private static class get_sentry_config_value_argsStandardScheme extends StandardScheme<get_sentry_config_value_args> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, get_sentry_config_value_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: // REQUEST + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.request = new TSentryConfigValueRequest(); + struct.request.read(iprot); + struct.setRequestIsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, get_sentry_config_value_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.request != null) { + oprot.writeFieldBegin(REQUEST_FIELD_DESC); + struct.request.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class get_sentry_config_value_argsTupleSchemeFactory implements SchemeFactory { + public get_sentry_config_value_argsTupleScheme getScheme() { + return new get_sentry_config_value_argsTupleScheme(); + } + } + + private static class get_sentry_config_value_argsTupleScheme extends TupleScheme<get_sentry_config_value_args> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, get_sentry_config_value_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetRequest()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetRequest()) { + struct.request.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, get_sentry_config_value_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.request = new TSentryConfigValueRequest(); + struct.request.read(iprot); + struct.setRequestIsSet(true); + } + } + } + + } + + public static class get_sentry_config_value_result implements org.apache.thrift.TBase<get_sentry_config_value_result, get_sentry_config_value_result._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("get_sentry_config_value_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 Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new get_sentry_config_value_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new get_sentry_config_value_resultTupleSchemeFactory()); + } + + private TSentryConfigValueResponse success; // 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"); + + 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 0: // SUCCESS + return SUCCESS; + 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.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, TSentryConfigValueResponse.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_sentry_config_value_result.class, metaDataMap); + } + + public get_sentry_config_value_result() { + } + + public get_sentry_config_value_result( + TSentryConfigValueResponse success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public get_sentry_config_value_result(get_sentry_config_value_result other) { + if (other.isSetSuccess()) { + this.success = new TSentryConfigValueResponse(other.success); + } + } + + public get_sentry_config_value_result deepCopy() { + return new get_sentry_config_value_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public TSentryConfigValueResponse getSuccess() { + return this.success; + } + + public void setSuccess(TSentryConfigValueResponse success) { + this.success = success; + } + + 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; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((TSentryConfigValueResponse)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + 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 SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_sentry_config_value_result) + return this.equals((get_sentry_config_value_result)that); + return false; + } + + public boolean equals(get_sentry_config_value_result that) { + if (that == null) + return false; + + 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; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + return builder.toHashCode(); + } + + public int compareTo(get_sentry_config_value_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_sentry_config_value_result typedOther = (get_sentry_config_value_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + 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("get_sentry_config_value_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + 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, 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 get_sentry_config_value_resultStandardSchemeFactory implements SchemeFactory { + public get_sentry_config_value_resultStandardScheme getScheme() { + return new get_sentry_config_value_resultStandardScheme(); + } + } + + private static class get_sentry_config_value_resultStandardScheme extends StandardScheme<get_sentry_config_value_result> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, get_sentry_config_value_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 TSentryConfigValueResponse(); + struct.success.read(iprot); + struct.setSuccessIsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, get_sentry_config_value_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(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class get_sentry_config_value_resultTupleSchemeFactory implements SchemeFactory { + public get_sentry_config_value_resultTupleScheme getScheme() { + return new get_sentry_config_value_resultTupleScheme(); + } + } + + private static class get_sentry_config_value_resultTupleScheme extends TupleScheme<get_sentry_config_value_result> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, get_sentry_config_value_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, get_sentry_config_value_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new TSentryConfigValueResponse(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueRequest.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueRequest.java new file mode 100644 index 0000000..c14393f --- /dev/null +++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueRequest.java @@ -0,0 +1,596 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.sentry.provider.db.service.thrift; + +import org.apache.commons.lang.builder.HashCodeBuilder; +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 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 TSentryConfigValueRequest implements org.apache.thrift.TBase<TSentryConfigValueRequest, TSentryConfigValueRequest._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSentryConfigValueRequest"); + + private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField PROPERTY_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("propertyName", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField DEFAULT_VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("defaultValue", org.apache.thrift.protocol.TType.STRING, (short)3); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TSentryConfigValueRequestStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSentryConfigValueRequestTupleSchemeFactory()); + } + + private int protocol_version; // required + private String propertyName; // required + private String defaultValue; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + PROTOCOL_VERSION((short)1, "protocol_version"), + PROPERTY_NAME((short)2, "propertyName"), + DEFAULT_VALUE((short)3, "defaultValue"); + + 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: // PROTOCOL_VERSION + return PROTOCOL_VERSION; + case 2: // PROPERTY_NAME + return PROPERTY_NAME; + case 3: // DEFAULT_VALUE + return DEFAULT_VALUE; + 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 + private static final int __PROTOCOL_VERSION_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private _Fields optionals[] = {_Fields.DEFAULT_VALUE}; + 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.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.PROPERTY_NAME, new org.apache.thrift.meta_data.FieldMetaData("propertyName", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DEFAULT_VALUE, new org.apache.thrift.meta_data.FieldMetaData("defaultValue", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSentryConfigValueRequest.class, metaDataMap); + } + + public TSentryConfigValueRequest() { + this.protocol_version = 1; + + } + + public TSentryConfigValueRequest( + int protocol_version, + String propertyName) + { + this(); + this.protocol_version = protocol_version; + setProtocol_versionIsSet(true); + this.propertyName = propertyName; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public TSentryConfigValueRequest(TSentryConfigValueRequest other) { + __isset_bitfield = other.__isset_bitfield; + this.protocol_version = other.protocol_version; + if (other.isSetPropertyName()) { + this.propertyName = other.propertyName; + } + if (other.isSetDefaultValue()) { + this.defaultValue = other.defaultValue; + } + } + + public TSentryConfigValueRequest deepCopy() { + return new TSentryConfigValueRequest(this); + } + + @Override + public void clear() { + this.protocol_version = 1; + + this.propertyName = null; + this.defaultValue = null; + } + + public int getProtocol_version() { + return this.protocol_version; + } + + public void setProtocol_version(int protocol_version) { + this.protocol_version = protocol_version; + setProtocol_versionIsSet(true); + } + + public void unsetProtocol_version() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID); + } + + /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */ + public boolean isSetProtocol_version() { + return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID); + } + + public void setProtocol_versionIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value); + } + + public String getPropertyName() { + return this.propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public void unsetPropertyName() { + this.propertyName = null; + } + + /** Returns true if field propertyName is set (has been assigned a value) and false otherwise */ + public boolean isSetPropertyName() { + return this.propertyName != null; + } + + public void setPropertyNameIsSet(boolean value) { + if (!value) { + this.propertyName = null; + } + } + + public String getDefaultValue() { + return this.defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public void unsetDefaultValue() { + this.defaultValue = null; + } + + /** Returns true if field defaultValue is set (has been assigned a value) and false otherwise */ + public boolean isSetDefaultValue() { + return this.defaultValue != null; + } + + public void setDefaultValueIsSet(boolean value) { + if (!value) { + this.defaultValue = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case PROTOCOL_VERSION: + if (value == null) { + unsetProtocol_version(); + } else { + setProtocol_version((Integer)value); + } + break; + + case PROPERTY_NAME: + if (value == null) { + unsetPropertyName(); + } else { + setPropertyName((String)value); + } + break; + + case DEFAULT_VALUE: + if (value == null) { + unsetDefaultValue(); + } else { + setDefaultValue((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case PROTOCOL_VERSION: + return Integer.valueOf(getProtocol_version()); + + case PROPERTY_NAME: + return getPropertyName(); + + case DEFAULT_VALUE: + return getDefaultValue(); + + } + 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 PROTOCOL_VERSION: + return isSetProtocol_version(); + case PROPERTY_NAME: + return isSetPropertyName(); + case DEFAULT_VALUE: + return isSetDefaultValue(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSentryConfigValueRequest) + return this.equals((TSentryConfigValueRequest)that); + return false; + } + + public boolean equals(TSentryConfigValueRequest that) { + if (that == null) + return false; + + boolean this_present_protocol_version = true; + boolean that_present_protocol_version = true; + if (this_present_protocol_version || that_present_protocol_version) { + if (!(this_present_protocol_version && that_present_protocol_version)) + return false; + if (this.protocol_version != that.protocol_version) + return false; + } + + boolean this_present_propertyName = true && this.isSetPropertyName(); + boolean that_present_propertyName = true && that.isSetPropertyName(); + if (this_present_propertyName || that_present_propertyName) { + if (!(this_present_propertyName && that_present_propertyName)) + return false; + if (!this.propertyName.equals(that.propertyName)) + return false; + } + + boolean this_present_defaultValue = true && this.isSetDefaultValue(); + boolean that_present_defaultValue = true && that.isSetDefaultValue(); + if (this_present_defaultValue || that_present_defaultValue) { + if (!(this_present_defaultValue && that_present_defaultValue)) + return false; + if (!this.defaultValue.equals(that.defaultValue)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_protocol_version = true; + builder.append(present_protocol_version); + if (present_protocol_version) + builder.append(protocol_version); + + boolean present_propertyName = true && (isSetPropertyName()); + builder.append(present_propertyName); + if (present_propertyName) + builder.append(propertyName); + + boolean present_defaultValue = true && (isSetDefaultValue()); + builder.append(present_defaultValue); + if (present_defaultValue) + builder.append(defaultValue); + + return builder.toHashCode(); + } + + public int compareTo(TSentryConfigValueRequest other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + TSentryConfigValueRequest typedOther = (TSentryConfigValueRequest)other; + + lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProtocol_version()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPropertyName()).compareTo(typedOther.isSetPropertyName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPropertyName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.propertyName, typedOther.propertyName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDefaultValue()).compareTo(typedOther.isSetDefaultValue()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDefaultValue()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.defaultValue, typedOther.defaultValue); + 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("TSentryConfigValueRequest("); + boolean first = true; + + sb.append("protocol_version:"); + sb.append(this.protocol_version); + first = false; + if (!first) sb.append(", "); + sb.append("propertyName:"); + if (this.propertyName == null) { + sb.append("null"); + } else { + sb.append(this.propertyName); + } + first = false; + if (isSetDefaultValue()) { + if (!first) sb.append(", "); + sb.append("defaultValue:"); + if (this.defaultValue == null) { + sb.append("null"); + } else { + sb.append(this.defaultValue); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetProtocol_version()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString()); + } + + if (!isSetPropertyName()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'propertyName' is unset! Struct:" + toString()); + } + + // 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 { + // 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); + } + } + + private static class TSentryConfigValueRequestStandardSchemeFactory implements SchemeFactory { + public TSentryConfigValueRequestStandardScheme getScheme() { + return new TSentryConfigValueRequestStandardScheme(); + } + } + + private static class TSentryConfigValueRequestStandardScheme extends StandardScheme<TSentryConfigValueRequest> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSentryConfigValueRequest 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: // PROTOCOL_VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.protocol_version = iprot.readI32(); + struct.setProtocol_versionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PROPERTY_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.propertyName = iprot.readString(); + struct.setPropertyNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // DEFAULT_VALUE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.defaultValue = iprot.readString(); + struct.setDefaultValueIsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSentryConfigValueRequest struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC); + oprot.writeI32(struct.protocol_version); + oprot.writeFieldEnd(); + if (struct.propertyName != null) { + oprot.writeFieldBegin(PROPERTY_NAME_FIELD_DESC); + oprot.writeString(struct.propertyName); + oprot.writeFieldEnd(); + } + if (struct.defaultValue != null) { + if (struct.isSetDefaultValue()) { + oprot.writeFieldBegin(DEFAULT_VALUE_FIELD_DESC); + oprot.writeString(struct.defaultValue); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSentryConfigValueRequestTupleSchemeFactory implements SchemeFactory { + public TSentryConfigValueRequestTupleScheme getScheme() { + return new TSentryConfigValueRequestTupleScheme(); + } + } + + private static class TSentryConfigValueRequestTupleScheme extends TupleScheme<TSentryConfigValueRequest> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSentryConfigValueRequest struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.protocol_version); + oprot.writeString(struct.propertyName); + BitSet optionals = new BitSet(); + if (struct.isSetDefaultValue()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetDefaultValue()) { + oprot.writeString(struct.defaultValue); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSentryConfigValueRequest struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.protocol_version = iprot.readI32(); + struct.setProtocol_versionIsSet(true); + struct.propertyName = iprot.readString(); + struct.setPropertyNameIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.defaultValue = iprot.readString(); + struct.setDefaultValueIsSet(true); + } + } + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueResponse.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueResponse.java new file mode 100644 index 0000000..e6430e9 --- /dev/null +++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryConfigValueResponse.java @@ -0,0 +1,500 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.sentry.provider.db.service.thrift; + +import org.apache.commons.lang.builder.HashCodeBuilder; +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 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 TSentryConfigValueResponse implements org.apache.thrift.TBase<TSentryConfigValueResponse, TSentryConfigValueResponse._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSentryConfigValueResponse"); + + private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", 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 TSentryConfigValueResponseStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TSentryConfigValueResponseTupleSchemeFactory()); + } + + private org.apache.sentry.service.thrift.TSentryResponseStatus status; // required + private String value; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STATUS((short)1, "status"), + VALUE((short)2, "value"); + + 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: // STATUS + return STATUS; + case 2: // VALUE + return VALUE; + 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 + private _Fields optionals[] = {_Fields.VALUE}; + 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.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.sentry.service.thrift.TSentryResponseStatus.class))); + tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSentryConfigValueResponse.class, metaDataMap); + } + + public TSentryConfigValueResponse() { + } + + public TSentryConfigValueResponse( + org.apache.sentry.service.thrift.TSentryResponseStatus status) + { + this(); + this.status = status; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public TSentryConfigValueResponse(TSentryConfigValueResponse other) { + if (other.isSetStatus()) { + this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status); + } + if (other.isSetValue()) { + this.value = other.value; + } + } + + public TSentryConfigValueResponse deepCopy() { + return new TSentryConfigValueResponse(this); + } + + @Override + public void clear() { + this.status = null; + this.value = null; + } + + public org.apache.sentry.service.thrift.TSentryResponseStatus getStatus() { + return this.status; + } + + public void setStatus(org.apache.sentry.service.thrift.TSentryResponseStatus status) { + this.status = status; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public void unsetValue() { + this.value = null; + } + + /** Returns true if field value is set (has been assigned a value) and false otherwise */ + public boolean isSetValue() { + return this.value != null; + } + + public void setValueIsSet(boolean value) { + if (!value) { + this.value = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value); + } + break; + + case VALUE: + if (value == null) { + unsetValue(); + } else { + setValue((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case VALUE: + return getValue(); + + } + 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 STATUS: + return isSetStatus(); + case VALUE: + return isSetValue(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TSentryConfigValueResponse) + return this.equals((TSentryConfigValueResponse)that); + return false; + } + + public boolean equals(TSentryConfigValueResponse that) { + if (that == null) + return false; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_value = true && this.isSetValue(); + boolean that_present_value = true && that.isSetValue(); + if (this_present_value || that_present_value) { + if (!(this_present_value && that_present_value)) + return false; + if (!this.value.equals(that.value)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_status = true && (isSetStatus()); + builder.append(present_status); + if (present_status) + builder.append(status); + + boolean present_value = true && (isSetValue()); + builder.append(present_value); + if (present_value) + builder.append(value); + + return builder.toHashCode(); + } + + public int compareTo(TSentryConfigValueResponse other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + TSentryConfigValueResponse typedOther = (TSentryConfigValueResponse)other; + + lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValue()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value); + 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("TSentryConfigValueResponse("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (isSetValue()) { + if (!first) sb.append(", "); + sb.append("value:"); + if (this.value == null) { + sb.append("null"); + } else { + sb.append(this.value); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetStatus()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + if (status != null) { + status.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, 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 TSentryConfigValueResponseStandardSchemeFactory implements SchemeFactory { + public TSentryConfigValueResponseStandardScheme getScheme() { + return new TSentryConfigValueResponseStandardScheme(); + } + } + + private static class TSentryConfigValueResponseStandardScheme extends StandardScheme<TSentryConfigValueResponse> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TSentryConfigValueResponse 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: // STATUS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // VALUE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.value = iprot.readString(); + struct.setValueIsSet(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(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, TSentryConfigValueResponse struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + struct.status.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.value != null) { + if (struct.isSetValue()) { + oprot.writeFieldBegin(VALUE_FIELD_DESC); + oprot.writeString(struct.value); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TSentryConfigValueResponseTupleSchemeFactory implements SchemeFactory { + public TSentryConfigValueResponseTupleScheme getScheme() { + return new TSentryConfigValueResponseTupleScheme(); + } + } + + private static class TSentryConfigValueResponseTupleScheme extends TupleScheme<TSentryConfigValueResponse> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TSentryConfigValueResponse struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + struct.status.write(oprot); + BitSet optionals = new BitSet(); + if (struct.isSetValue()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetValue()) { + oprot.writeString(struct.value); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TSentryConfigValueResponse struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(); + struct.status.read(iprot); + struct.setStatusIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.value = iprot.readString(); + struct.setValueIsSet(true); + } + } + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java index 65905f5..39371b7 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java @@ -69,7 +69,7 @@ public class SentryPolicyServiceClient { private int connectionTimeout; private static final Logger LOGGER = LoggerFactory .getLogger(SentryPolicyServiceClient.class); - private static final String THRIFT_EXCEPTION_MESSAGE = "Thrift exception occured "; + private static final String THRIFT_EXCEPTION_MESSAGE = "Thrift exception occurred "; /** * This transport wraps the Sasl transports to set up the right UGI context for open(). @@ -602,6 +602,32 @@ TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName, } } + /** + * Returns the configuration value in the sentry server associated with + * propertyName, or if propertyName does not exist, the defaultValue. + * There is no "requestorUserName" because this is regarded as an + * internal interface. + * @param propertyName Config attribute to search for + * @param defaultValue String to return if not found + * @return The value of the propertyName + * @throws SentryUserException + */ + public String getConfigValue(String propertyName, String defaultValue) + throws SentryUserException { + TSentryConfigValueRequest request = new TSentryConfigValueRequest( + ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT, propertyName); + if (defaultValue != null) { + request.setDefaultValue(defaultValue); + } + try { + TSentryConfigValueResponse response = client.get_sentry_config_value(request); + Status.throwIfNotOk(response.getStatus()); + return response.getValue(); + } catch (TException e) { + throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e); + } + } + public void close() { if (transport != null) { transport.close(); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java index b54e12e..6de9992 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import org.apache.hadoop.conf.Configuration; import org.apache.sentry.SentryUserException; @@ -589,4 +590,34 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface { return response; } + /** + * Respond to a request for a config value in the sentry server. The client + * can request any config value that starts with "sentry." and doesn't contain + * "keytab". + * @param request Contains config parameter sought and default if not found + * @return The response, containing the value and status + * @throws TException + */ + @Override + public TSentryConfigValueResponse get_sentry_config_value( + TSentryConfigValueRequest request) throws TException { + + TSentryConfigValueResponse response = new TSentryConfigValueResponse(); + String attr = request.getPropertyName(); + + // Only allow config parameters like... + if (!Pattern.matches("^sentry\\..*", attr) || + Pattern.matches(".*keytab.*", attr)) { + String msg = "Attempted access of the configuration property " + attr + + " was denied"; + LOGGER.error(msg); + response.setStatus(Status.AccessDenied(msg, + new SentryAccessDeniedException(msg))); + return response; + } + + response.setValue(conf.get(attr,request.getDefaultValue())); + response.setStatus(Status.OK()); + return response; + } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift index d9a3913..7e6ade5 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift @@ -216,6 +216,17 @@ struct TListSentryPrivilegesByAuthResponse { 2: optional map<TSentryAuthorizable, TSentryPrivilegeMap> privilegesMapByAuth # will not be set in case of an error } +# Obtain a config value from the Sentry service +struct TSentryConfigValueRequest { +1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1, +2: required string propertyName, # Config attribute to obtain +3: optional string defaultValue # Value if propertyName not found +} +struct TSentryConfigValueResponse { +1: required sentry_common_service.TSentryResponseStatus status +2: optional string value +} + service SentryPolicyService { TCreateSentryRoleResponse create_sentry_role(1:TCreateSentryRoleRequest request) @@ -239,4 +250,6 @@ service SentryPolicyService TRenamePrivilegesResponse rename_sentry_privilege(1:TRenamePrivilegesRequest request); TListSentryPrivilegesByAuthResponse list_sentry_privileges_by_authorizable(1:TListSentryPrivilegesByAuthRequest request); + + TSentryConfigValueResponse get_sentry_config_value(1:TSentryConfigValueRequest request) } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/2fb35eb9/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java index ff6cff4..23bd765 100644 --- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java +++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import org.apache.sentry.SentryUserException; import org.apache.sentry.core.common.ActiveRoleSet; import org.apache.sentry.core.common.Authorizable; import org.apache.sentry.core.model.db.AccessConstants; @@ -636,4 +637,62 @@ public class TestSentryServiceIntegration extends SentryServiceIntegrationBase { // expected } } + + @Test + public void testGetConfigVal() throws Exception { + String val; + + // Basic success case + val = client.getConfigValue("sentry.service.admin.group", "xxx"); + assertEquals(val, "admin_group"); + + // Undefined value gets the default back + val = client.getConfigValue("sentry.this.is.not.defined", "hello"); + assertEquals(val, "hello"); + + // Undefined value and null default gets null back + val = client.getConfigValue("sentry.this.is.not.defined", null); + assertEquals(val, null); + + // Known config value with null default works as expected + val = client.getConfigValue("sentry.service.admin.group", null); + assertEquals(val, "admin_group"); + + // Value that is forbidden (anything not starting with "sentry") dies + try { + val = client.getConfigValue("notsentry", "xxx"); + fail("Attempt to access banned config value succeeded"); + } catch (SentryAccessDeniedException e) { + assertTrue(e.toString().contains("was denied")); + assertTrue(e.toString().contains("notsentry")); + // expected + } + + // Ditto with a null default + try { + val = client.getConfigValue("notsentry", null); + fail("Attempt to access banned config value succeeded"); + } catch (SentryAccessDeniedException e) { + assertTrue(e.toString().contains("was denied")); + assertTrue(e.toString().contains("notsentry")); + // expected + } + + // Attempt to get the location of the keytab also fails + try { + val = client.getConfigValue("sentry.service.server.keytab", "xxx"); + fail("Attempt to access banned keytab succeeded"); + } catch (SentryAccessDeniedException e) { + assertTrue(e.toString().contains("was denied")); + assertTrue(e.toString().contains("keytab")); + } + + // null parameter name fails + try { + val = client.getConfigValue(null, null); + fail("null parameter succeeded"); + } catch (SentryUserException e) { + // expected + } + } }
