public void writeToZookeeper(byte[] data, boolean labelsOrUserAuths) throws IOException { // Update local state, then send it to zookeeper if (labelsOrUserAuths) { // True for labels this.refreshLabelsCache(data); } else { // False for user auths this.refreshUserAuthsCache(data); } this.zkVisibilityWatcher.writeToZookeeper(data, labelsOrUserAuths); } }
protected boolean isReadFromSystemAuthUser() throws IOException { User user = VisibilityUtils.getActiveUser(); return havingSystemAuth(user); }
@Override public ReplicationEndpoint postCreateReplicationEndPoint( ObserverContext<RegionServerCoprocessorEnvironment> ctx, ReplicationEndpoint endpoint) { return new VisibilityReplicationEndpoint(endpoint, visibilityLabelService); } }
/** * Utility method for adding label to the system. * * @param connection * @param label * @return VisibilityLabelsResponse * @throws Throwable */ public static VisibilityLabelsResponse addLabel(Connection connection, final String label) throws Throwable { return addLabels(connection, new String[] { label }); }
@Override public List<String> getLabels(User user, Authorizations authorizations) { if (authorizations != null) { return authorizations.getLabels(); } return null; } }
private boolean tagMatched(Cell put, TagInfo delInfo) throws IOException { List<Tag> putVisTags = new ArrayList<>(); Byte putCellVisTagsFormat = VisibilityUtils.extractVisibilityTags(put, putVisTags); return putVisTags.isEmpty() == delInfo.tags.isEmpty() && ( (putVisTags.isEmpty() && delInfo.tags.isEmpty()) || VisibilityLabelServiceManager .getInstance().getVisibilityLabelService() .matchVisibility(putVisTags, putCellVisTagsFormat, delInfo.tags, delInfo.format)); }
/** * @param putVisTags Visibility tags in Put Mutation * @param deleteVisTags Visibility tags in Delete Mutation * @return true when all the visibility tags in Put matches with visibility tags in Delete. * This is used when, at least one set of tags are not sorted based on the label ordinal. */ private static boolean matchUnSortedVisibilityTags(List<Tag> putVisTags, List<Tag> deleteVisTags) throws IOException { return compareTagsOrdinals(sortTagsBasedOnOrdinal(putVisTags), sortTagsBasedOnOrdinal(deleteVisTags)); }
public static final boolean isValidLabel(byte[] label) { for (int i = 0; i < label.length; i++) { if (!isValidAuthChar(label[i])) { return false; } } return true; } }
protected boolean isReadFromSystemAuthUser() throws IOException { User user = VisibilityUtils.getActiveUser(); return havingSystemAuth(user); }
/** * Sets given labels globally authorized for the user. * @param connection * @param auths * @param user * @return VisibilityLabelsResponse * @throws Throwable */ public static VisibilityLabelsResponse setAuths(Connection connection, final String[] auths, final String user) throws Throwable { return setOrClearAuths(connection, auths, user, true); }
public DefinedSetFilterScanLabelGenerator() { this.labelsCache = VisibilityLabelsCache.get(); }
@Test public void testDeleteCellWithVisibility() throws IOException, InterruptedException { for (DeleteMark mark : DeleteMark.values()) { testDeleteCellWithVisibility(mark); testDeleteCellWithVisibilityV2(mark); } }
@Override public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c, final InternalScanner s, final List<Result> result, final int limit, final boolean hasNext) throws IOException { requireScannerOwner(s); return hasNext; }
@Override protected void resetInternal() { delFamMap.put(Long.MAX_VALUE, new VisibilityDeleteVersionsNode(Long.MIN_VALUE, Long.MAX_VALUE, new TagInfo())); } }
@Test public void testDeleteCellWithoutVisibility() throws IOException, InterruptedException { for (DeleteMark mark : DeleteMark.values()) { testDeleteCellWithoutVisibility(mark); } }
@Override public boolean matchVisibility(List<Tag> putTags, Byte putTagsFormat, List<Tag> deleteTags, Byte deleteTagsFormat) throws IOException { assert putTagsFormat == STRING_SERIALIZATION_FORMAT; assert deleteTagsFormat == STRING_SERIALIZATION_FORMAT; return checkForMatchingVisibilityTagsWithSortedOrder(putTags, deleteTags); }
private TableName createTable() throws IOException { return createTable(-1); }
/** * Removes given labels from user's globally authorized list of labels. * @param connection * @param auths * @param user * @return VisibilityLabelsResponse * @throws Throwable */ public static VisibilityLabelsResponse clearAuths(Connection connection, final String[] auths, final String user) throws Throwable { return setOrClearAuths(connection, auths, user, false); }
public EnforcingScanLabelGenerator() { this.labelsCache = VisibilityLabelsCache.get(); }
@Override public void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c, final InternalScanner s) throws IOException { requireScannerOwner(s); }