/** * Convert a protocol buffer CellVisibility to a client CellVisibility * * @param proto * @return the converted client CellVisibility */ private static CellVisibility toCellVisibility(ClientProtos.CellVisibility proto) { if (proto == null) return null; return new CellVisibility(proto.getExpression()); }
/** * Create a protocol buffer CellVisibility based on a client CellVisibility. * * @param cellVisibility * @return a protocol buffer CellVisibility */ static ClientProtos.CellVisibility toCellVisibility(CellVisibility cellVisibility) { ClientProtos.CellVisibility.Builder builder = ClientProtos.CellVisibility.newBuilder(); builder.setExpression(cellVisibility.getExpression()); return builder.build(); }
/** * Helps in quoting authentication Strings. Use this if unicode characters to * be used in expression or special characters like '(', ')', * '"','\','&','|','!' */ public static String quote(String auth) { return quote(Bytes.toBytes(auth)); }
&& !put.getCellVisibility().getExpression().equals(column.getVisibility()) )) { put = new Put(rowKey); put.setCellVisibility(new CellVisibility(column.getVisibility()));
&& !put.getCellVisibility().getExpression().equals(column.getVisibility()) )) { put = new Put(rowKey); put.setCellVisibility(new CellVisibility(column.getVisibility()));
/** * Convert a protocol buffer CellVisibility to a client CellVisibility * * @param proto * @return the converted client CellVisibility */ public static CellVisibility toCellVisibility(ClientProtos.CellVisibility proto) { if (proto == null) return null; return new CellVisibility(proto.getExpression()); }
if (cellVisibility == null && tag != null) { cellVisibility = new CellVisibility(Tag.getValueAsString(tag)); modifiedTagFound = true; String labelsExp = cellVisibility.getExpression(); List<Tag> visibilityTags = labelCache.get(labelsExp); if (visibilityTags == null) {
/** * Create a protocol buffer CellVisibility based on a client CellVisibility. * * @param cellVisibility * @return a protocol buffer CellVisibility */ public static ClientProtos.CellVisibility toCellVisibility(CellVisibility cellVisibility) { ClientProtos.CellVisibility.Builder builder = ClientProtos.CellVisibility.newBuilder(); builder.setExpression(cellVisibility.getExpression()); return builder.build(); }
.append(VisibilityConstants.NOT_OPERATOR).append(CellVisibility.quote(label)); } else { visibilityString.append(VisibilityConstants.AND_OPERATOR) .append(VisibilityConstants.NOT_OPERATOR).append(CellVisibility.quote(label)); if (expressionStart) { visibilityString.append(VisibilityConstants.OPEN_PARAN).append( CellVisibility.quote(label)); } else { visibilityString.append(VisibilityConstants.AND_OPERATOR).append( CellVisibility.quote(label));
@Override public void delete(String tableName, List<byte[]> rowIds, String visibilityLabel) throws IOException { List<Delete> deletes = new ArrayList<>(); for (int index = 0; index < rowIds.size(); index++) { Delete delete = new Delete(rowIds.get(index)); if (!StringUtils.isBlank(visibilityLabel)) { delete.setCellVisibility(new CellVisibility(visibilityLabel)); } deletes.add(delete); } batchDelete(tableName, deletes); }
private Cell createNewCellWithTags(Mutation mutation, Cell newCell) throws IOException { List<Tag> tags = Lists.newArrayList(); CellVisibility cellVisibility = null; try { cellVisibility = mutation.getCellVisibility(); } catch (DeserializationException e) { throw new IOException(e); } if (cellVisibility == null) { return newCell; } // Prepend new visibility tags to a new list of tags for the cell // Don't check user auths for labels with Mutations when the user is super user boolean authCheck = authorizationEnabled && checkAuths && !(isSystemOrSuperUser()); tags.addAll(this.visibilityLabelService.createVisibilityExpTags(cellVisibility.getExpression(), true, authCheck)); // Carry forward all other tags Iterator<Tag> tagsItr = PrivateCellUtil.tagsIterator(newCell); while (tagsItr.hasNext()) { Tag tag = tagsItr.next(); if (tag.getType() != TagType.VISIBILITY_TAG_TYPE && tag.getType() != TagType.VISIBILITY_EXP_SERIALIZATION_FORMAT_TAG_TYPE) { tags.add(tag); } } return PrivateCellUtil.createCell(newCell, tags); }
if (expressionStart) { visibilityString.append(VisibilityConstants.OPEN_PARAN + VisibilityConstants.NOT_OPERATOR + CellVisibility.quote(label)); } else { visibilityString.append(VisibilityConstants.AND_OPERATOR + VisibilityConstants.NOT_OPERATOR + CellVisibility.quote(label)); visibilityString.append(VisibilityConstants.OPEN_PARAN + CellVisibility.quote(label)); } else { visibilityString.append(VisibilityConstants.AND_OPERATOR + CellVisibility.quote(label));
@Override public void delete(String tableName, List<byte[]> rowIds, String visibilityLabel) throws IOException { List<Delete> deletes = new ArrayList<>(); for (int index = 0; index < rowIds.size(); index++) { Delete delete = new Delete(rowIds.get(index)); if (!StringUtils.isBlank(visibilityLabel)) { delete.setCellVisibility(new CellVisibility(visibilityLabel)); } deletes.add(delete); } batchDelete(tableName, deletes); }
String labelsExp = cellVisibility.getExpression(); try { visibilityTags = this.visibilityLabelService.createVisibilityExpTags(labelsExp, false,
} catch (ParseException e) { node = parser.parse(CellVisibility.quote("\u0027") + "&" + CellVisibility.quote("\"") + "|" + CellVisibility.quote("\u002b" + "&" + "\u003f")); assertTrue(node instanceof NonLeafExpressionNode); NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node; assertEquals("\u0027", ((LeafExpressionNode) nlNode.getChildExps().get(0)).getIdentifier()); try { node = parser.parse(CellVisibility.quote("\u0027&\\") + "|" + CellVisibility.quote("\u002b" + "&" + "\\") + CellVisibility.quote("$$\"")); fail("Excpetion must be thrown as there is not operator"); } catch (ParseException e) { node = parser.parse(CellVisibility.quote("\u0027" + "&" + "\\") + "|" + CellVisibility.quote("\u003f" + "&" + "\\") + "&" + CellVisibility.quote("$$\"")); assertTrue(node instanceof NonLeafExpressionNode); nlNode = (NonLeafExpressionNode) node; ((LeafExpressionNode) nlNode.getChildExps().get(1)).getIdentifier()); try { node = parser.parse(CellVisibility.quote("\u002b&\\") + "|" + CellVisibility.quote("\u0027&\\") + "&" + "\"$$"); fail("Excpetion must be thrown as there is no end quote");
@Override public void delete(String tableName, byte[] rowId, String visibilityLabel) throws IOException { try (final Table table = connection.getTable(TableName.valueOf(tableName))) { Delete delete = new Delete(rowId); if (!StringUtils.isEmpty(visibilityLabel)) { delete.setCellVisibility(new CellVisibility(visibilityLabel)); } table.delete(delete); } }
.createVisibilityExpTags(cellVisibility.getExpression()));
@Test public void testNonAsciiCases() throws Exception { ExpressionNode node = parser.parse(CellVisibility.quote("\u0027") + "&" + CellVisibility.quote("\u002b") + "|" + CellVisibility.quote("\u002d") + "&" + CellVisibility.quote("\u003f")); assertTrue(node instanceof NonLeafExpressionNode); NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node; assertEquals("\u0027", ((LeafExpressionNode) nlNode.getChildExps().get(0)).getIdentifier()); node = parser.parse(CellVisibility.quote("\u0027") + "&" + CellVisibility.quote("\u002b") + "|" + CellVisibility.quote("\u002d") + "&" + CellVisibility.quote("\u003f")); assertTrue(node instanceof NonLeafExpressionNode); nlNode = (NonLeafExpressionNode) node;
@Override public void delete(String tableName, byte[] rowId, String visibilityLabel) throws IOException { try (final Table table = connection.getTable(TableName.valueOf(tableName))) { Delete delete = new Delete(rowId); if (!StringUtils.isEmpty(visibilityLabel)) { delete.setCellVisibility(new CellVisibility(visibilityLabel)); } table.delete(delete); } }
if (cellVisibility != null) { TCellVisibility tCellVisibility = new TCellVisibility(); tCellVisibility.setExpression(cellVisibility.getExpression()); out.setCellVisibility(tCellVisibility);