/** * Performs a deep copy on <i>other</i>. */ public AccessControl(AccessControl other) { __isset_bitfield = other.__isset_bitfield; if (other.is_set_type()) { this.type = other.type; } if (other.is_set_name()) { this.name = other.name; } this.access = other.access; }
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((is_set_type()) ? 131071 : 524287); if (is_set_type()) hashCode = hashCode * 8191 + type.getValue(); hashCode = hashCode * 8191 + ((is_set_name()) ? 131071 : 524287); if (is_set_name()) hashCode = hashCode * 8191 + name.hashCode(); hashCode = hashCode * 8191 + access; return hashCode; }
@Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("AccessControl("); boolean first = true; sb.append("type:"); if (this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; if (is_set_name()) { if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; } if (!first) sb.append(", "); sb.append("access:"); sb.append(this.access); first = false; sb.append(")"); return sb.toString(); }
/** 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 java.lang.IllegalArgumentException(); } switch (field) { case TYPE: return is_set_type(); case NAME: return is_set_name(); case ACCESS: return is_set_access(); } throw new java.lang.IllegalStateException(); }
public static String accessControlToString(AccessControl ac) { StringBuilder ret = new StringBuilder(); switch (ac.get_type()) { case OTHER: ret.append("o"); break; case USER: ret.append("u"); break; default: throw new IllegalArgumentException("Don't know what a type of " + ac.get_type() + " means "); } ret.append(":"); if (ac.is_set_name()) { ret.append(ac.get_name()); } ret.append(":"); ret.append(accessToString(ac.get_access())); return ret.toString(); }
@Override public void write(org.apache.storm.thrift.protocol.TProtocol prot, AccessControl struct) throws org.apache.storm.thrift.TException { org.apache.storm.thrift.protocol.TTupleProtocol oprot = (org.apache.storm.thrift.protocol.TTupleProtocol) prot; oprot.writeI32(struct.type.getValue()); oprot.writeI32(struct.access); java.util.BitSet optionals = new java.util.BitSet(); if (struct.is_set_name()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.is_set_name()) { oprot.writeString(struct.name); } }
boolean this_present_name = true && this.is_set_name(); boolean that_present_name = true && that.is_set_name(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name))
private void fixEmptyNameACLForUsers(List<AccessControl> acls, Set<String> users, int mask) { List<AccessControl> aclsToAdd = new ArrayList<>(); List<AccessControl> aclsToRemove = new ArrayList<>(); for (AccessControl control : acls) { if (control.get_type() == AccessControlType.USER && !control.is_set_name()) { aclsToRemove.add(control); int currentAccess = control.get_access(); if ((currentAccess & mask) != mask) { control.set_access(currentAccess | mask); } for (String user : users) { AccessControl copiedControl = new AccessControl(control); copiedControl.set_name(user); aclsToAdd.add(copiedControl); } } } acls.removeAll(aclsToRemove); acls.addAll(aclsToAdd); }
lastComparison = java.lang.Boolean.valueOf(is_set_name()).compareTo(other.is_set_name()); if (lastComparison != 0) { return lastComparison; if (is_set_name()) { lastComparison = org.apache.storm.thrift.TBaseHelper.compareTo(this.name, other.name); if (lastComparison != 0) {
private void fixACLsForUser(List<AccessControl> acls, String user, int mask) { boolean foundUserACL = false; List<AccessControl> emptyUserACLs = new ArrayList<>(); for (AccessControl control : acls) { if (control.get_type() == AccessControlType.USER) { if (!control.is_set_name()) { emptyUserACLs.add(control); } else if (control.get_name().equals(user)) { int currentAccess = control.get_access(); if ((currentAccess & mask) != mask) { control.set_access(currentAccess | mask); } foundUserACL = true; } } } // if ACLs have two user ACLs for empty user and principal, discard empty user ACL if (!emptyUserACLs.isEmpty() && foundUserACL) { acls.removeAll(emptyUserACLs); } // add default user ACL when only empty user ACL is not present if (emptyUserACLs.isEmpty() && !foundUserACL) { AccessControl userACL = new AccessControl(); userACL.set_type(AccessControlType.USER); userACL.set_name(user); userACL.set_access(mask); acls.add(userACL); } }
public void write(org.apache.storm.thrift.protocol.TProtocol oprot, AccessControl struct) throws org.apache.storm.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeI32(struct.type.getValue()); oprot.writeFieldEnd(); } if (struct.name != null) { if (struct.is_set_name()) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } } oprot.writeFieldBegin(ACCESS_FIELD_DESC); oprot.writeI32(struct.access); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); }
/** * Performs a deep copy on <i>other</i>. */ public AccessControl(AccessControl other) { __isset_bitfield = other.__isset_bitfield; if (other.is_set_type()) { this.type = other.type; } if (other.is_set_name()) { this.name = other.name; } this.access = other.access; }
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_type = true && (is_set_type()); list.add(present_type); if (present_type) list.add(type.getValue()); boolean present_name = true && (is_set_name()); list.add(present_name); if (present_name) list.add(name); boolean present_access = true; list.add(present_access); if (present_access) list.add(access); return list.hashCode(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("AccessControl("); boolean first = true; sb.append("type:"); if (this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; if (is_set_name()) { if (!first) sb.append(", "); sb.append("name:"); if (this.name == null) { sb.append("null"); } else { sb.append(this.name); } first = false; } if (!first) sb.append(", "); sb.append("access:"); sb.append(this.access); first = false; sb.append(")"); return sb.toString(); }
/** 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 is_set_type(); case NAME: return is_set_name(); case ACCESS: return is_set_access(); } throw new IllegalStateException(); }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, AccessControl struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeI32(struct.type.getValue()); oprot.writeI32(struct.access); BitSet optionals = new BitSet(); if (struct.is_set_name()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.is_set_name()) { oprot.writeString(struct.name); } }
public static String accessControlToString(AccessControl ac) { StringBuilder ret = new StringBuilder(); switch(ac.get_type()) { case OTHER: ret.append("o"); break; case USER: ret.append("u"); break; default: throw new IllegalArgumentException("Don't know what a type of "+ac.get_type()+" means "); } ret.append(":"); if (ac.is_set_name()) { ret.append(ac.get_name()); } ret.append(":"); ret.append(accessToString(ac.get_access())); return ret.toString(); }
public boolean equals(AccessControl that) { if (that == null) return false; boolean this_present_type = true && this.is_set_type(); boolean that_present_type = true && that.is_set_type(); 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_name = true && this.is_set_name(); boolean that_present_name = true && that.is_set_name(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) return false; if (!this.name.equals(that.name)) return false; } boolean this_present_access = true; boolean that_present_access = true; if (this_present_access || that_present_access) { if (!(this_present_access && that_present_access)) return false; if (this.access != that.access) return false; } return true; }
private void fixEmptyNameACLForUsers(List<AccessControl> acls, Set<String> users, int mask) { List<AccessControl> aclsToAdd = new ArrayList<>(); List<AccessControl> aclsToRemove = new ArrayList<>(); for (AccessControl control : acls) { if (control.get_type() == AccessControlType.USER && !control.is_set_name()) { aclsToRemove.add(control); int currentAccess = control.get_access(); if ((currentAccess & mask) != mask) { control.set_access(currentAccess | mask); } for (String user : users) { AccessControl copiedControl = new AccessControl(control); copiedControl.set_name(user); aclsToAdd.add(copiedControl); } } } acls.removeAll(aclsToRemove); acls.addAll(aclsToAdd); }
public void write(org.apache.thrift.protocol.TProtocol oprot, AccessControl struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeI32(struct.type.getValue()); oprot.writeFieldEnd(); } if (struct.name != null) { if (struct.is_set_name()) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } } oprot.writeFieldBegin(ACCESS_FIELD_DESC); oprot.writeI32(struct.access); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); }