public TPrivilegePrincipal deepCopy() { return new TPrivilegePrincipal(this); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TPrivilegePrincipal) return this.equals((TPrivilegePrincipal)that); return false; }
/** * Performs a deep copy on <i>other</i>. */ public TPrivilegePrincipal(TPrivilegePrincipal other) { if (other.isSetType()) { this.type = other.type; } if (other.isSetValue()) { this.value = other.value; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case TYPE: if (value == null) { unsetType(); } else { setType((TPrivilegePrincipalType)value); } break; case VALUE: if (value == null) { unsetValue(); } else { setValue((String)value); } break; } }
public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetType()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); } if (!isSetValue()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' is unset! Struct:" + toString()); } // check for sub-struct validity }
if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType.findByValue(iprot.readI32()); struct.setTypeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); 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); struct.validate();
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TPrivilegePrincipal struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType.findByValue(iprot.readI32()); struct.setTypeIsSet(true); struct.value = iprot.readString(); struct.setValueIsSet(true); } }
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); } }
/** 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 TYPE: return isSetType(); case VALUE: return isSetValue(); } throw new IllegalStateException(); }
private static Map<TPrivilegePrincipal, String> addPrivilegeEntry(MSentryPrivilege mPriv, TPrivilegePrincipalType tEntityType, String principal, Map<TPrivilegePrincipal, String> update) { TPrivilegePrincipal tPrivilegePrincipal = new TPrivilegePrincipal(tEntityType, principal); String existingPriv = update.get(tPrivilegePrincipal); String action = mPriv.getAction().toUpperCase(); String newAction = mPriv.getAction().toUpperCase(); if(action.equals(AccessConstants.OWNER)) { // Translate owner privilege to actual privilege. newAction = AccessConstants.ACTION_ALL; } if (existingPriv == null) { update.put(tPrivilegePrincipal, newAction); } else { update.put(tPrivilegePrincipal, existingPriv + "," + newAction); } return update; }
public boolean equals(TPrivilegePrincipal that) { if (that == null) return false; boolean this_present_type = true && this.isSetType(); boolean that_present_type = true && that.isSetType(); if (this_present_type || that_present_type) { if (!(this_present_type && that_present_type)) return false; if (!this.type.equals(that.type)) 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; }
/** * Constructs permission update to be persisted for rename event that can be persisted from thrift * object. * * @param oldAuthorizable old thrift object * @param newAuthorizable new thrift object * @return update to be persisted * @throws SentryInvalidInputException if the required fields are set in arguments provided */ @VisibleForTesting static Update getPermUpdatableOnRename(TSentryAuthorizable oldAuthorizable, TSentryAuthorizable newAuthorizable) throws SentryInvalidInputException { String oldAuthz = SentryServiceUtil.getAuthzObj(oldAuthorizable); String newAuthz = SentryServiceUtil.getAuthzObj(newAuthorizable); PermissionsUpdate update = new PermissionsUpdate(SentryConstants.INIT_CHANGE_ID, false); TPrivilegeChanges privUpdate = update.addPrivilegeUpdate(PermissionsUpdate.RENAME_PRIVS); privUpdate.putToAddPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.AUTHZ_OBJ, newAuthz), newAuthz); privUpdate.putToDelPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.AUTHZ_OBJ, oldAuthz), oldAuthz); return update; }
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_type = true && (isSetType()); list.add(present_type); if (present_type) list.add(type.getValue()); boolean present_value = true && (isSetValue()); list.add(present_value); if (present_value) list.add(value); return list.hashCode(); }
/** * Constructs permission update to be persisted for drop event that can be persisted * from thrift object. * * @param authorizable thrift object that is dropped. * @return update to be persisted * @throws SentryInvalidInputException if the required fields are set in argument provided */ @VisibleForTesting static Update getPermUpdatableOnDrop(TSentryAuthorizable authorizable) throws SentryInvalidInputException { PermissionsUpdate update = new PermissionsUpdate(SentryConstants.INIT_CHANGE_ID, false); String authzObj = SentryServiceUtil.getAuthzObj(authorizable); // The value of TPrivilegePrincipal being PermissionsUpdate.ALL_PRIVS indicates that all privileges // associated with this authorizable should be deleted, including both role and user, i.e., // the key value of TPrivilegePrincipalType.ROLE is ignored. update.addPrivilegeUpdate(authzObj) .putToDelPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, PermissionsUpdate.ALL_PRIVS), PermissionsUpdate.ALL_PRIVS); return update; }
@Override public int compareTo(TPrivilegePrincipal other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); if (lastComparison != 0) { return lastComparison; } if (isSetType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetValue()).compareTo(other.isSetValue()); if (lastComparison != 0) { return lastComparison; } if (isSetValue()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, other.value); if (lastComparison != 0) { return lastComparison; } } return 0; }
assertEquals("ALL", privs.get("db3.tbl1").get(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, roleName1))); assertEquals("ALL", privs.get("db3.tbl1").get(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, roleName2)));
Map<String, Map<TPrivilegePrincipal, String>> privs = permImage.getPrivilegeImage(); assertEquals(1, privs.get("db1.tbl1").size()); assertEquals("REFRESH,INSERT,SELECT", privs.get("db1.tbl1").get(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, roleName1)));
new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, roleName), privilege.getAction().toUpperCase()); new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, roleName), privilege.getAction().toUpperCase());
PermissionsUpdate renameUpdate = new PermissionsUpdate(0, false); TPrivilegeChanges privUpdate = renameUpdate.addPrivilegeUpdate(PermissionsUpdate.RENAME_PRIVS); privUpdate.putToAddPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.AUTHZ_OBJ, newAuthz), newAuthz); privUpdate.putToDelPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.AUTHZ_OBJ, oldAuthz), oldAuthz);