private TListSentryPrivilegesRequest newPrivilegesRequest(String requestorUser, String principalName, TSentryAuthorizable authorizable) { TListSentryPrivilegesRequest request = new TListSentryPrivilegesRequest(); request.setRequestorUserName(requestorUser); request.setPrincipalName(principalName); request.setAuthorizableHierarchy(authorizable); return request; }
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 AUTHORIZABLE_HIERARCHY: return getAuthorizableHierarchy(); case PRINCIPAL_NAME: return getPrincipalName(); } 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 REQUESTOR_USER_NAME: return isSetRequestorUserName(); case ROLE_NAME: return isSetRoleName(); case AUTHORIZABLE_HIERARCHY: return isSetAuthorizableHierarchy(); case PRINCIPAL_NAME: return isSetPrincipalName(); } 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); unsetAuthorizableHierarchy(); } else { setAuthorizableHierarchy((TSentryAuthorizable)value); unsetPrincipalName(); } else { setPrincipalName((String)value);
@Override public Set<TSentryPrivilege> listPrivilegesByUserName(String requestorUserName, String userName, List<? extends Authorizable> authorizable) throws SentryUserException { TListSentryPrivilegesRequest request = new TListSentryPrivilegesRequest(); request.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT); request.setRequestorUserName(requestorUserName); // TODO: Remove setRoleName() once the required field is removed request.setRoleName(""); // roleName is unused by it is required by Thrift request.setPrincipalName(userName); if (authorizable != null && !authorizable.isEmpty()) { TSentryAuthorizable tSentryAuthorizable = setupSentryAuthorizable(authorizable); request.setAuthorizableHierarchy(tSentryAuthorizable); } TListSentryPrivilegesResponse response; try { response = client.list_sentry_privileges_by_user(request); if (response == null) { throw new SentryUserException("The Sentry server has returned a NULL response. " + "See the Sentry server logs for more information about the error."); } Status.throwIfNotOk(response.getStatus()); return response.getPrivileges(); } catch (TException e) { throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_privileges_by_user_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.request = new TListSentryPrivilegesRequest(); struct.request.read(iprot); struct.setRequestIsSet(true); } } }
public void write(org.apache.thrift.protocol.TProtocol oprot, TListSentryPrivilegesRequest struct) throws org.apache.thrift.TException { struct.validate(); if (struct.isSetAuthorizableHierarchy()) { oprot.writeFieldBegin(AUTHORIZABLE_HIERARCHY_FIELD_DESC); struct.authorizableHierarchy.write(oprot); if (struct.isSetPrincipalName()) { oprot.writeFieldBegin(PRINCIPAL_NAME_FIELD_DESC); oprot.writeString(struct.principalName);
@Override public void write(org.apache.thrift.protocol.TProtocol prot, TListSentryPrivilegesRequest struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeI32(struct.protocol_version); oprot.writeString(struct.requestorUserName); oprot.writeString(struct.roleName); BitSet optionals = new BitSet(); if (struct.isSetAuthorizableHierarchy()) { optionals.set(0); } if (struct.isSetPrincipalName()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetAuthorizableHierarchy()) { struct.authorizableHierarchy.write(oprot); } if (struct.isSetPrincipalName()) { oprot.writeString(struct.principalName); } }
public TListSentryPrivilegesRequest deepCopy() { return new TListSentryPrivilegesRequest(this); }
String roleName, List<? extends Authorizable> authorizable) throws SentryUserException { TListSentryPrivilegesRequest request = new TListSentryPrivilegesRequest(); request.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT); request.setRequestorUserName(requestorUserName); request.setRoleName(roleName); if (authorizable != null && !authorizable.isEmpty()) { TSentryAuthorizable tSentryAuthorizable = setupSentryAuthorizable(authorizable); request.setAuthorizableHierarchy(tSentryAuthorizable);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_privileges_by_role_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.request = new TListSentryPrivilegesRequest(); struct.request.read(iprot); struct.setRequestIsSet(true); } } }
if (isSetAuthorizableHierarchy()) { if (!first) sb.append(", "); sb.append("authorizableHierarchy:"); if (isSetPrincipalName()) { if (!first) sb.append(", "); sb.append("principalName:");
/** * Performs a deep copy on <i>other</i>. */ public list_sentry_privileges_by_role_args(list_sentry_privileges_by_role_args other) { if (other.isSetRequest()) { this.request = new TListSentryPrivilegesRequest(other.request); } }
TSentryResponseStatus status; Set<TSentryPrivilege> privilegeSet = new HashSet<TSentryPrivilege>(); String subject = request.getRequestorUserName(); String roleName = (request.getPrincipalName() != null) ? request.getPrincipalName() : request.getRoleName(); validateClientVersion(request.getProtocol_version()); Set<String> groups = getRequestorGroups(subject); Boolean admin = inAdminGroups(groups); if (request.isSetAuthorizableHierarchy()) { TSentryAuthorizable authorizableHierarchy = request.getAuthorizableHierarchy(); privilegeSet = sentryStore.getTSentryPrivileges(SentryPrincipalType.ROLE, Sets.newHashSet(roleName), authorizableHierarchy); } else {
/** * Performs a deep copy on <i>other</i>. */ public TListSentryPrivilegesRequest(TListSentryPrivilegesRequest 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.isSetAuthorizableHierarchy()) { this.authorizableHierarchy = new TSentryAuthorizable(other.authorizableHierarchy); } if (other.isSetPrincipalName()) { this.principalName = other.principalName; } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_privileges_by_user_and_itsgroups_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.request = new TListSentryPrivilegesRequest(); struct.request.read(iprot); struct.setRequestIsSet(true); } } }
/** * Performs a deep copy on <i>other</i>. */ public list_sentry_privileges_by_user_args(list_sentry_privileges_by_user_args other) { if (other.isSetRequest()) { this.request = new TListSentryPrivilegesRequest(other.request); } }
TSentryResponseStatus status = checkRequiredParameter(request.getPrincipalName(), "principalName parameter must not be null"); if (status != null) { String requestor = request.getRequestorUserName(); String principalName = request.getPrincipalName().trim(); Set<TSentryPrivilege> privilegeSet = new HashSet<>(); validateClientVersion(request.getProtocol_version()); principalGroups, principalUsers, new TSentryActiveRoleSet(true, null), request.getAuthorizableHierarchy())); response.setPrivileges(privilegeSet); response.setStatus(Status.OK());
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_authorizableHierarchy = true && this.isSetAuthorizableHierarchy(); boolean that_present_authorizableHierarchy = true && that.isSetAuthorizableHierarchy(); if (this_present_authorizableHierarchy || that_present_authorizableHierarchy) { if (!(this_present_authorizableHierarchy && that_present_authorizableHierarchy)) boolean this_present_principalName = true && this.isSetPrincipalName(); boolean that_present_principalName = true && that.isSetPrincipalName(); if (this_present_principalName || that_present_principalName) { if (!(this_present_principalName && that_present_principalName))
public void read(org.apache.thrift.protocol.TProtocol iprot, list_sentry_privileges_by_user_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 TListSentryPrivilegesRequest(); 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(); }