public void refreshUserAuthsCache(byte[] data) throws IOException { MultiUserAuthorizations multiUserAuths = null; try { multiUserAuths = VisibilityUtils.readUserAuthsFromZKData(data); } catch (DeserializationException dse) { throw new IOException(dse); } this.lock.writeLock().lock(); try { this.userAuths.clear(); this.groupAuths.clear(); for (UserAuthorizations userAuths : multiUserAuths.getUserAuthsList()) { String user = Bytes.toString(userAuths.getUser().toByteArray()); if (AuthUtil.isGroupPrincipal(user)) { this.groupAuths.put(AuthUtil.getGroupName(user), new HashSet<>(userAuths.getAuthList())); } else { this.userAuths.put(user, new HashSet<>(userAuths.getAuthList())); } } } finally { this.lock.writeLock().unlock(); } }
/** * Creates the user auth data to be written to zookeeper. * @param userAuths * @return Bytes form of user auths details to be written to zookeeper. */ public static byte[] getUserAuthsDataToWriteToZooKeeper(Map<String, List<Integer>> userAuths) { MultiUserAuthorizations.Builder builder = MultiUserAuthorizations.newBuilder(); for (Entry<String, List<Integer>> entry : userAuths.entrySet()) { UserAuthorizations.Builder userAuthsBuilder = UserAuthorizations.newBuilder(); userAuthsBuilder.setUser(ByteString.copyFrom(Bytes.toBytes(entry.getKey()))); for (Integer label : entry.getValue()) { userAuthsBuilder.addAuth(label); } builder.addUserAuths(userAuthsBuilder.build()); } return ProtobufUtil.prependPBMagic(builder.build().toByteArray()); }
public org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations buildPartial() { org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations result = new org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.user_ = user_; if (((bitField0_ & 0x00000002) == 0x00000002)) { auth_ = java.util.Collections.unmodifiableList(auth_); bitField0_ = (bitField0_ & ~0x00000002); } result.auth_ = auth_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public void refreshUserAuthsCache(byte[] data) throws IOException { MultiUserAuthorizations multiUserAuths = null; try { multiUserAuths = VisibilityUtils.readUserAuthsFromZKData(data); } catch (DeserializationException dse) { throw new IOException(dse); } this.lock.writeLock().lock(); try { this.userAuths.clear(); this.groupAuths.clear(); for (UserAuthorizations userAuths : multiUserAuths.getUserAuthsList()) { String user = Bytes.toString(userAuths.getUser().toByteArray()); if (AuthUtil.isGroupPrincipal(user)) { this.groupAuths.put(AuthUtil.getGroupName(user), new HashSet<Integer>(userAuths.getAuthList())); } else { this.userAuths.put(user, new HashSet<Integer>(userAuths.getAuthList())); } } } finally { this.lock.writeLock().unlock(); } }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.facebook.presto.hbase.$internal.com.google.protobuf.CodedOutputStream .computeBytesSize(1, user_); } { int dataSize = 0; for (int i = 0; i < auth_.size(); i++) { dataSize += com.facebook.presto.hbase.$internal.com.google.protobuf.CodedOutputStream .computeUInt32SizeNoTag(auth_.get(i)); } size += dataSize; size += 1 * getAuthList().size(); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(1, user_); } { int dataSize = 0; for (int i = 0; i < auth_.size(); i++) { dataSize += com.google.protobuf.CodedOutputStream .computeUInt32SizeNoTag(auth_.get(i)); } size += dataSize; size += 1 * getAuthList().size(); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations)) { return super.equals(obj); } org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other = (org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations) obj; boolean result = true; result = result && (hasUser() == other.hasUser()); if (hasUser()) { result = result && getUser() .equals(other.getUser()); } result = result && getAuthList() .equals(other.getAuthList()); result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations)) { return super.equals(obj); } org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other = (org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations) obj; boolean result = true; result = result && (hasUser() == other.hasUser()); if (hasUser()) { result = result && getUser() .equals(other.getUser()); } result = result && getAuthList() .equals(other.getAuthList()); result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(1, user_); } { int dataSize = 0; for (int i = 0; i < auth_.size(); i++) { dataSize += com.google.protobuf.CodedOutputStream .computeUInt32SizeNoTag(auth_.get(i)); } size += dataSize; size += 1 * getAuthList().size(); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations)) { return super.equals(obj); } org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other = (org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations) obj; boolean result = true; result = result && (hasUser() == other.hasUser()); if (hasUser()) { result = result && getUser() .equals(other.getUser()); } result = result && getAuthList() .equals(other.getAuthList()); result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other) { if (other == org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations.getDefaultInstance()) return this; if (other.hasUser()) { setUser(other.getUser()); } if (!other.auth_.isEmpty()) { if (auth_.isEmpty()) { auth_ = other.auth_; bitField0_ = (bitField0_ & ~0x00000002); } else { ensureAuthIsMutable(); auth_.addAll(other.auth_); } onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations buildPartial() { org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations result = new org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.user_ = user_; if (((bitField0_ & 0x00000002) == 0x00000002)) { auth_ = java.util.Collections.unmodifiableList(auth_); bitField0_ = (bitField0_ & ~0x00000002); } result.auth_ = auth_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public Builder toBuilder() { return newBuilder(this); }
/** * Creates the user auth data to be written to zookeeper. * @param userAuths * @return Bytes form of user auths details to be written to zookeeper. */ public static byte[] getUserAuthsDataToWriteToZooKeeper(Map<String, List<Integer>> userAuths) { MultiUserAuthorizations.Builder builder = MultiUserAuthorizations.newBuilder(); for (Entry<String, List<Integer>> entry : userAuths.entrySet()) { UserAuthorizations.Builder userAuthsBuilder = UserAuthorizations.newBuilder(); userAuthsBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(entry.getKey()))); for (Integer label : entry.getValue()) { userAuthsBuilder.addAuth(label); } builder.addUserAuths(userAuthsBuilder.build()); } return ProtobufUtil.prependPBMagic(builder.build().toByteArray()); }
public org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations buildPartial() { org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations result = new org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.user_ = user_; if (((bitField0_ & 0x00000002) == 0x00000002)) { auth_ = java.util.Collections.unmodifiableList(auth_); bitField0_ = (bitField0_ & ~0x00000002); } result.auth_ = auth_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (hasUser()) { hash = (37 * hash) + USER_FIELD_NUMBER; hash = (53 * hash) + getUser().hashCode(); } if (getAuthCount() > 0) { hash = (37 * hash) + AUTH_FIELD_NUMBER; hash = (53 * hash) + getAuthList().hashCode(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other) { if (other == org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations.getDefaultInstance()) return this; if (other.hasUser()) { setUser(other.getUser()); } if (!other.auth_.isEmpty()) { if (auth_.isEmpty()) { auth_ = other.auth_; bitField0_ = (bitField0_ & ~0x00000002); } else { ensureAuthIsMutable(); auth_.addAll(other.auth_); } onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (hasUser()) { hash = (37 * hash) + USER_FIELD_NUMBER; hash = (53 * hash) + getUser().hashCode(); } if (getAuthCount() > 0) { hash = (37 * hash) + AUTH_FIELD_NUMBER; hash = (53 * hash) + getAuthList().hashCode(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations other) { if (other == org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations.getDefaultInstance()) return this; if (other.hasUser()) { setUser(other.getUser()); } if (!other.auth_.isEmpty()) { if (auth_.isEmpty()) { auth_ = other.auth_; bitField0_ = (bitField0_ & ~0x00000002); } else { ensureAuthIsMutable(); auth_.addAll(other.auth_); } onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations buildPartial() { org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations result = new org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.UserAuthorizations(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.user_ = user_; if (((bitField0_ & 0x00000002) == 0x00000002)) { auth_ = java.util.Collections.unmodifiableList(auth_); bitField0_ = (bitField0_ & ~0x00000002); } result.auth_ = auth_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }