@Override public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_privileges_by_role_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new TListSentryPrivilegesResponse(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } }
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 PRIVILEGES: if (value == null) { unsetPrivileges(); } else { setPrivileges((Set<TSentryPrivilege>)value); } break; } }
public Object getFieldValue(_Fields field) { switch (field) { case STATUS: return getStatus(); case PRIVILEGES: return getPrivileges(); } 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 PRIVILEGES: return isSetPrivileges(); } throw new IllegalStateException(); }
TListSentryPrivilegesRequest request) throws TException { final Timer.Context timerContext = sentryMetrics.listPrivilegesByUserTimer.time(); TListSentryPrivilegesResponse response = new TListSentryPrivilegesResponse(); Set<TSentryPrivilege> privilegeSet = new HashSet<TSentryPrivilege>(); String subject = request.getRequestorUserName(); "principalName parameter must not be null"); if (status != null) { response.setStatus(status); return response; response.setPrivileges(privilegeSet); response.setStatus(Status.OK()); } catch (SentryNoSuchObjectException e) { response.setPrivileges(privilegeSet); String msg = "Privilege: " + request + " couldn't be retrieved."; LOGGER.error(msg, e); response.setStatus(Status.NoSuchObject(msg, e)); } catch (SentryAccessDeniedException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryGroupNotFoundException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryThriftAPIMismatchException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e)); } catch (Exception e) { String msg = "Unknown error for request: " + request + ", message: " + e.getMessage();
expectedResp = new TListSentryPrivilegesResponse(); expectedResp.setStatus(Status.InvalidInput("principalName parameter must not be null", new SentryInvalidInputException("principalName parameter must not be null"))); Assert.assertEquals(expectedResp.getStatus().getValue(), returnedResp.getStatus().getValue()); Assert.assertEquals(2, returnedResp.getPrivileges().size()); Assert.assertEquals(Status.OK(), returnedResp.getStatus()); assertTrue("User should have ALL privileges in db1.t1", returnedResp.getPrivileges().contains(newSentryPrivilege("database", "db1", "t1", "*"))); assertTrue("User should have ALL privileges in db1.t2", returnedResp.getPrivileges().contains(newSentryPrivilege("database", "db1", "t2", "*"))); Assert.assertEquals(2, returnedResp.getPrivileges().size()); Assert.assertEquals(Status.OK(), returnedResp.getStatus()); assertTrue("User should have ALL privileges in db1.t1", returnedResp.getPrivileges().contains(newSentryPrivilege("database", "db1", "t1", "*"))); assertTrue("User should have ALL privileges in db1.t2", returnedResp.getPrivileges().contains(newSentryPrivilege("database", "db1", "t2", "*"))); Assert.assertEquals(Status.ACCESS_DENIED.getCode(), returnedResp.getStatus().getValue()); assertNull(returnedResp.getPrivileges()); Assert.assertEquals(1, returnedResp.getPrivileges().size()); Assert.assertEquals(Status.OK(), returnedResp.getStatus()); assertTrue("User should have ALL privileges in db1.t1", returnedResp.getPrivileges().contains(newSentryPrivilege("database", "db1", "t1", "*")));
public TListSentryPrivilegesResponse deepCopy() { return new TListSentryPrivilegesResponse(this); }
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(); } }
public void write(org.apache.thrift.protocol.TProtocol oprot, TListSentryPrivilegesResponse 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.privileges != null) { if (struct.isSetPrivileges()) { oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size())); for (TSentryPrivilege _iter75 : struct.privileges) { _iter75.write(oprot); } oprot.writeSetEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TListSentryPrivilegesResponse) return this.equals((TListSentryPrivilegesResponse)that); return false; }
@Override public String toString() { StringBuilder sb = new StringBuilder("TListSentryPrivilegesResponse("); boolean first = true; sb.append("status:"); if (this.status == null) { sb.append("null"); } else { sb.append(this.status); } first = false; if (isSetPrivileges()) { if (!first) sb.append(", "); sb.append("privileges:"); if (this.privileges == null) { sb.append("null"); } else { sb.append(this.privileges); } first = false; } sb.append(")"); return sb.toString(); }
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); } }
TListSentryPrivilegesRequest request) throws TException { final Timer.Context timerContext = sentryMetrics.listPrivilegesForUserTimer.time(); TListSentryPrivilegesResponse response = new TListSentryPrivilegesResponse(); "principalName parameter must not be null"); if (status != null) { response.setStatus(status); return response; new TSentryActiveRoleSet(true, null), request.getAuthorizableHierarchy())); response.setPrivileges(privilegeSet); response.setStatus(Status.OK()); } catch (SentryThriftAPIMismatchException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e)); } catch (SentryAccessDeniedException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryInvalidInputException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.InvalidInput(e.getMessage(), e)); } catch (SentryUserException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (Exception e) { String msg = "Unknown error for request: " + request + ", message: " + e.getMessage(); LOGGER.error(msg, e); response.setStatus(Status.RuntimeError(msg, e));
/** * Performs a deep copy on <i>other</i>. */ public list_sentry_privileges_by_user_result(list_sentry_privileges_by_user_result other) { if (other.isSetSuccess()) { this.success = new TListSentryPrivilegesResponse(other.success); } }
public boolean equals(TListSentryPrivilegesResponse 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_privileges = true && this.isSetPrivileges(); boolean that_present_privileges = true && that.isSetPrivileges(); if (this_present_privileges || that_present_privileges) { if (!(this_present_privileges && that_present_privileges)) return false; if (!this.privileges.equals(that.privileges)) return false; } return true; }
public boolean equals(list_sentry_privileges_by_role_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 void write(org.apache.thrift.protocol.TProtocol prot, TListSentryPrivilegesResponse struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; struct.status.write(oprot); BitSet optionals = new BitSet(); if (struct.isSetPrivileges()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetPrivileges()) { { oprot.writeI32(struct.privileges.size()); for (TSentryPrivilege _iter76 : struct.privileges) { _iter76.write(oprot); } } } }
TListSentryPrivilegesRequest request) throws TException { final Timer.Context timerContext = sentryMetrics.listPrivilegesByRoleTimer.time(); TListSentryPrivilegesResponse response = new TListSentryPrivilegesResponse(); TSentryResponseStatus status; Set<TSentryPrivilege> privilegeSet = new HashSet<TSentryPrivilege>(); response.setPrivileges(privilegeSet); response.setStatus(Status.OK()); } catch (SentryNoSuchObjectException e) { response.setPrivileges(privilegeSet); String msg = "Privilege: " + request + " couldn't be retrieved."; LOGGER.error(msg, e); response.setStatus(Status.NoSuchObject(msg, e)); } catch (SentryAccessDeniedException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryGroupNotFoundException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.AccessDenied(e.getMessage(), e)); } catch (SentryThriftAPIMismatchException e) { LOGGER.error(e.getMessage(), e); response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e)); } catch (Exception e) { String msg = "Unknown error for request: " + request + ", message: " + e.getMessage(); LOGGER.error(msg, e); response.setStatus(Status.RuntimeError(msg, e)); } finally { timerContext.stop();
@Override public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_privileges_by_user_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new TListSentryPrivilegesResponse(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } }
try { response = client.list_sentry_privileges_by_role(request); Status.throwIfNotOk(response.getStatus()); return response.getPrivileges(); } catch (TException e) { throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);