public TDropSentryRoleRequest deepCopy() { return new TDropSentryRoleRequest(this); }
public Object getFieldValue(_Fields field) { switch (field) { case PROTOCOL_VERSION: return getProtocol_version(); case REQUESTOR_USER_NAME: return getRequestorUserName(); case ROLE_NAME: return getRoleName(); case COMPONENT: return getComponent(); } throw new IllegalStateException(); }
case PROTOCOL_VERSION: if (value == null) { unsetProtocol_version(); } else { setProtocol_version((Integer)value); unsetRequestorUserName(); } else { setRequestorUserName((String)value); unsetRoleName(); } else { setRoleName((String)value); unsetComponent(); } else { setComponent((String)value);
/** * Performs a deep copy on <i>other</i>. */ public TDropSentryRoleRequest(TDropSentryRoleRequest other) { __isset_bitfield = other.__isset_bitfield; this.protocol_version = other.protocol_version; if (other.isSetRequestorUserName()) { this.requestorUserName = other.requestorUserName; } if (other.isSetRoleName()) { this.roleName = other.roleName; } if (other.isSetComponent()) { this.component = other.component; } }
/** 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 REQUESTOR_USER_NAME: return isSetRequestorUserName(); case ROLE_NAME: return isSetRoleName(); case COMPONENT: return isSetComponent(); } throw new IllegalStateException(); }
@Test public void testDropRole() { TDropSentryRoleRequest request = new TDropSentryRoleRequest(); TDropSentryRoleResponse response = new TDropSentryRoleResponse(); request.setRequestorUserName(TEST_USER_NAME); request.setRoleName(TEST_ROLE_NAME); response.setStatus(Status.OK()); GMAuditMetadataLogEntity amle = (GMAuditMetadataLogEntity) JsonLogEntityFactory .getInstance().createJsonLogEntity(request, response, conf); assertCommon(amle, Constants.TRUE, Constants.OPERATION_DROP_ROLE, "DROP ROLE testRole", Constants.OBJECT_TYPE_ROLE, new HashMap<String, String>()); response.setStatus(Status.InvalidInput("", null)); amle = (GMAuditMetadataLogEntity) JsonLogEntityFactory.getInstance().createJsonLogEntity( request, response, conf); assertCommon(amle, Constants.FALSE, Constants.OPERATION_DROP_ROLE, "DROP ROLE testRole", Constants.OBJECT_TYPE_ROLE, new HashMap<String, String>()); }
private void dropRole(String requestorUserName, String roleName, String component, boolean ifExists) throws SentryUserException { TDropSentryRoleRequest request = new TDropSentryRoleRequest(); request.setProtocol_version(sentry_common_serviceConstants.TSENTRY_SERVICE_V2); request.setRequestorUserName(requestorUserName); request.setRoleName(roleName); request.setComponent(component); try { TDropSentryRoleResponse response = client.drop_sentry_role(request); Status status = Status.fromCode(response.getStatus().getValue()); if (ifExists && status == Status.NO_SUCH_OBJECT) { return; } Status.throwIfNotOk(response.getStatus()); } catch (TException e) { throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e); } }
public JsonLogEntity createJsonLogEntity( org.apache.sentry.api.generic.thrift.TDropSentryRoleRequest request, org.apache.sentry.api.generic.thrift.TDropSentryRoleResponse response, Configuration conf) { GMAuditMetadataLogEntity gmamle = createCommonGMAMLE(conf, response.getStatus(), request.getRequestorUserName(), request.getClass().getName(), request.getComponent()); gmamle.setOperationText(CommandUtil.createCmdForCreateOrDropRole(request.getRoleName(), false)); return gmamle; }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, drop_sentry_role_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.request = new TDropSentryRoleRequest(); struct.request.read(iprot); struct.setRequestIsSet(true); } } }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TDropSentryRoleRequest) return this.equals((TDropSentryRoleRequest)that); return false; }
assertEquals(Status.ALREADY_EXISTS, fromTSentryStatus(processor.create_sentry_role(createrequest).getStatus())); TDropSentryRoleRequest dropRequest = new TDropSentryRoleRequest(); dropRequest.setRequestorUserName(ADMIN_USER); dropRequest.setRoleName("r1"); assertEquals(Status.NO_SUCH_OBJECT, fromTSentryStatus(processor.drop_sentry_role(dropRequest).getStatus()));
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 (!isSetRequestorUserName()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString()); } if (!isSetRoleName()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'roleName' is unset! Struct:" + toString()); } if (!isSetComponent()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'component' is unset! Struct:" + toString()); } // check for sub-struct validity }
boolean this_present_requestorUserName = true && this.isSetRequestorUserName(); boolean that_present_requestorUserName = true && that.isSetRequestorUserName(); if (this_present_requestorUserName || that_present_requestorUserName) { if (!(this_present_requestorUserName && that_present_requestorUserName)) boolean this_present_roleName = true && this.isSetRoleName(); boolean that_present_roleName = true && that.isSetRoleName(); if (this_present_roleName || that_present_roleName) { if (!(this_present_roleName && that_present_roleName)) boolean this_present_component = true && this.isSetComponent(); boolean that_present_component = true && that.isSetComponent(); if (this_present_component || that_present_component) { if (!(this_present_component && that_present_component))
public void read(org.apache.thrift.protocol.TProtocol iprot, drop_sentry_role_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 TDropSentryRoleRequest(); 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 boolean equals(drop_sentry_role_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; }
private void testOperation(String requestUser, Status validateStatus) throws Exception { TCreateSentryRoleRequest createrequest = new TCreateSentryRoleRequest(); createrequest.setRequestorUserName(requestUser); createrequest.setRoleName("r1"); assertEquals(validateStatus, fromTSentryStatus(processor.create_sentry_role(createrequest).getStatus())); TDropSentryRoleRequest dropRequest = new TDropSentryRoleRequest(); dropRequest.setRequestorUserName(requestUser); dropRequest.setRoleName("r1"); assertEquals(validateStatus, fromTSentryStatus(processor.drop_sentry_role(dropRequest).getStatus())); TAlterSentryRoleAddGroupsRequest addRequest = new TAlterSentryRoleAddGroupsRequest(); addRequest.setRequestorUserName(requestUser); addRequest.setRoleName("r1"); addRequest.setGroups(Sets.newHashSet("g1")); assertEquals(validateStatus, fromTSentryStatus(processor.alter_sentry_role_add_groups(addRequest).getStatus())); TAlterSentryRoleDeleteGroupsRequest delRequest = new TAlterSentryRoleDeleteGroupsRequest(); delRequest.setRequestorUserName(requestUser); delRequest.setRoleName("r1"); delRequest.setGroups(Sets.newHashSet("g1")); assertEquals(validateStatus, fromTSentryStatus(processor.alter_sentry_role_delete_groups(delRequest).getStatus())); TDropPrivilegesRequest dropPrivRequest = new TDropPrivilegesRequest(); dropPrivRequest.setRequestorUserName(requestUser); dropPrivRequest.setPrivilege(new TSentryPrivilege("test", "test", new ArrayList<TAuthorizable>(), "test")); assertEquals(validateStatus, fromTSentryStatus(processor.drop_sentry_privilege(dropPrivRequest).getStatus())); TRenamePrivilegesRequest renameRequest = new TRenamePrivilegesRequest(); renameRequest.setRequestorUserName(requestUser); assertEquals(validateStatus, fromTSentryStatus(processor.rename_sentry_privilege(renameRequest).getStatus())); }
@Override public Response<Void> handle() throws Exception { validateClientVersion(request.getProtocol_version()); authorize(request.getRequestorUserName(), getRequestorGroups(conf, request.getRequestorUserName())); store.dropRole(request.getComponent(), request.getRoleName(), request.getRequestorUserName()); return new Response<Void>(Status.OK()); } });
lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(other.isSetProtocol_version()); if (lastComparison != 0) { return lastComparison; if (isSetProtocol_version()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, other.protocol_version); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(other.isSetRequestorUserName()); if (lastComparison != 0) { return lastComparison; if (isSetRequestorUserName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, other.requestorUserName); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetRoleName()).compareTo(other.isSetRoleName()); if (lastComparison != 0) { return lastComparison; if (isSetRoleName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.roleName, other.roleName); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetComponent()).compareTo(other.isSetComponent()); if (lastComparison != 0) { return lastComparison; if (isSetComponent()) {
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_protocol_version = true; list.add(present_protocol_version); if (present_protocol_version) list.add(protocol_version); boolean present_requestorUserName = true && (isSetRequestorUserName()); list.add(present_requestorUserName); if (present_requestorUserName) list.add(requestorUserName); boolean present_roleName = true && (isSetRoleName()); list.add(present_roleName); if (present_roleName) list.add(roleName); boolean present_component = true && (isSetComponent()); list.add(present_component); if (present_component) list.add(component); return list.hashCode(); }
/** * Performs a deep copy on <i>other</i>. */ public drop_sentry_role_args(drop_sentry_role_args other) { if (other.isSetRequest()) { this.request = new TDropSentryRoleRequest(other.request); } }