private <E extends Enum<?>> SearchCond complex( final String operator, final String left, final String right, final List<SCIMComplexConf<E>> items) { if (left.endsWith(".type")) { Optional<SCIMComplexConf<E>> item = items.stream(). filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst(); if (item.isPresent()) { AttributeCond attributeCond = new AttributeCond(); attributeCond.setSchema(item.get().getValue()); attributeCond.setType(AttributeCond.Type.ISNOTNULL); return SearchCond.getLeafCond(attributeCond); } } else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) { List<SearchCond> orConds = new ArrayList<>(); items.forEach(item -> { AttributeCond cond = new AttributeCond(); cond.setSchema(item.getValue()); cond.setExpression(StringUtils.strip(right, "\"")); orConds.add(setOperator(cond, operator)); }); if (!orConds.isEmpty()) { return SearchCond.getOrCond(orConds); } } return null; }
case "eq": default: attributeCond.setType(AttributeCond.Type.IEQ); break; attributeCond.setType(AttributeCond.Type.IEQ); break; attributeCond.setType(AttributeCond.Type.ILIKE); attributeCond.setExpression(attributeCond.getExpression() + "%"); break; attributeCond.setType(AttributeCond.Type.ILIKE); attributeCond.setExpression("%" + attributeCond.getExpression() + "%"); break; attributeCond.setType(AttributeCond.Type.ILIKE); attributeCond.setExpression("%" + attributeCond.getExpression()); break; attributeCond.setType(AttributeCond.Type.GT); break; attributeCond.setType(AttributeCond.Type.GE); break; attributeCond.setType(AttributeCond.Type.LT); break;
protected Pair<PlainSchema, PlainAttrValue> check(final AttributeCond cond, final AnyTypeKind kind) { AnyUtils anyUtils = anyUtilsFactory.getInstance(kind); PlainSchema schema = schemaDAO.find(cond.getSchema()); if (schema == null) { LOG.warn("Ignoring invalid schema '{}'", cond.getSchema()); throw new IllegalArgumentException(); } PlainAttrValue attrValue = schema.isUniqueConstraint() ? anyUtils.newPlainAttrUniqueValue() : anyUtils.newPlainAttrValue(); try { if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ILIKE && cond.getType() != AttributeCond.Type.ISNULL && cond.getType() != AttributeCond.Type.ISNOTNULL) { ((JPAPlainSchema) schema).validator().validate(cond.getExpression(), attrValue); } } catch (ValidationException e) { LOG.error("Could not validate expression '" + cond.getExpression() + "'", e); throw new IllegalArgumentException(); } return Pair.of(schema, attrValue); }
private AttributeCond createAttributeCond(final String schema) { AttributeCond attributeCond = SearchableFields.contains(schema) ? new AnyCond() : new AttributeCond(); attributeCond.setSchema(schema); return attributeCond; }
user = userDAO.findByUsername(authentication.getName()); } else { AttributeCond attrCond = new AttributeCond(AttributeCond.Type.EQ); attrCond.setSchema(authAttrValues.get(i)); attrCond.setExpression(authentication.getName()); List<User> users = searchDAO.search(SearchCond.getLeafCond(attrCond), AnyTypeKind.USER); if (users.size() == 1) {
attributeCond.setExpression(value); if (!specialAttrName.isPresent()) { if (specialAttrValue.isPresent() && specialAttrValue.get() == SpecialAttr.NULL) { attributeCond.setType(AttributeCond.Type.ISNULL); attributeCond.setExpression(null); } else if (value.indexOf('%') == -1) { attributeCond.setType(sc.getConditionType() == ConditionType.CUSTOM ? AttributeCond.Type.IEQ : AttributeCond.Type.EQ); } else { attributeCond.setType(sc.getConditionType() == ConditionType.CUSTOM ? AttributeCond.Type.ILIKE : AttributeCond.Type.LIKE); && leaf.getAttributeCond().getType() == AttributeCond.Type.ISNULL) { leaf.getAttributeCond().setType(AttributeCond.Type.ISNOTNULL); } else if (leaf.getAnyCond() != null && leaf.getAnyCond().getType() == AttributeCond.Type.ISNULL) { attributeCond.setType(AttributeCond.Type.GE); leaf = SearchCond.getLeafCond(attributeCond); break; attributeCond.setType(AttributeCond.Type.GT); leaf = SearchCond.getLeafCond(attributeCond); break;
@Override public SearchCond visitNOT_EXPR(final SCIMFilterParser.NOT_EXPRContext ctx) { SearchCond cond = visit(ctx.expression()); if (cond.getAttributeCond() != null) { if (cond.getAttributeCond().getType() == AttributeCond.Type.ISNULL) { cond.getAttributeCond().setType(AttributeCond.Type.ISNOTNULL); } else if (cond.getAttributeCond().getType() == AttributeCond.Type.ISNOTNULL) { cond.getAttributeCond().setType(AttributeCond.Type.ISNULL); } } else if (cond.getAnyCond() != null) { if (cond.getAnyCond().getType() == AnyCond.Type.ISNULL) { cond.getAnyCond().setType(AnyCond.Type.ISNOTNULL); } else if (cond.getAnyCond().getType() == AnyCond.Type.ISNOTNULL) { cond.getAnyCond().setType(AnyCond.Type.ISNULL); } } else { cond = SearchCond.getNotLeafCond(cond); } return cond; }
attributeCond.setExpression(StringUtils.strip(right, "\"")); result = setOperator(attributeCond, operator);
@Override public SearchCond visitATTR_PR(final SCIMFilterParser.ATTR_PRContext ctx) { AttributeCond cond = createAttributeCond(ctx.ATTRNAME().getText()); cond.setType(AttributeCond.Type.ISNOTNULL); return SearchCond.getLeafCond(cond); }
switch (cond.getType()) { case ISNOTNULL: query.append(checked.getLeft().isUniqueConstraint()
user = userDAO.findByUsername(authentication.getName()); } else { AttributeCond attrCond = new AttributeCond(AttributeCond.Type.EQ); attrCond.setSchema(authAttrValues.get(i)); attrCond.setExpression(authentication.getName()); List<User> users = searchDAO.search(SearchCond.getLeafCond(attrCond), AnyTypeKind.USER); if (users.size() == 1) {
attributeCond.setSchema("username"); } else if (resource == Resource.Group && schemaEquals(Resource.Group, "displayName", schema)) { attributeCond = new AnyCond(); attributeCond.setSchema("name"); } else if (schemaEquals(null, "meta.created", schema)) { attributeCond = new AnyCond(); attributeCond.setSchema("creationDate"); } else if (schemaEquals(null, "meta.lastModified", schema)) { attributeCond = new AnyCond(); attributeCond.setSchema("lastChangeDate"); for (Map.Entry<String, String> entry : conf.getUserConf().getName().asMap().entrySet()) { if (schemaEquals(Resource.User, "name." + entry.getKey(), schema)) { attributeCond = new AttributeCond(); attributeCond.setSchema(entry.getValue()); attributeCond = new AttributeCond(); attributeCond.setSchema(entry.getValue()); for (Map.Entry<String, String> entry : address.asMap().entrySet()) { if (schemaEquals(Resource.User, "addresses." + entry.getKey(), schema)) { attributeCond = new AttributeCond(); attributeCond.setSchema(entry.getValue()); for (Map.Entry<String, String> entry : conf.getEnterpriseUserConf().asMap().entrySet()) { if (schemaEquals(Resource.EnterpriseUser, entry.getKey(), schema)) { attributeCond = new AttributeCond(); attributeCond.setSchema(entry.getValue());
private SearchCond addresses( final String operator, final String left, final String right, final List<SCIMUserAddressConf> items) { if (left.endsWith(".type") && "eq".equals(operator)) { Optional<SCIMUserAddressConf> item = items.stream(). filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst(); if (item.isPresent()) { AttributeCond attributeCond = new AttributeCond(); attributeCond.setSchema(item.get().getFormatted()); attributeCond.setType(AttributeCond.Type.ISNOTNULL); return SearchCond.getLeafCond(attributeCond); } } else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) { List<SearchCond> orConds = new ArrayList<>(); items.forEach(item -> { AttributeCond cond = new AttributeCond(); cond.setSchema(item.getFormatted()); cond.setExpression(StringUtils.strip(right, "\"")); orConds.add(setOperator(cond, operator)); }); if (!orConds.isEmpty()) { return SearchCond.getOrCond(orConds); } } return null; }
&& cond.getType() != AttributeCond.Type.ISNULL && cond.getType() != AttributeCond.Type.ISNOTNULL) { } else { boolean ignoreCase = AttributeCond.Type.ILIKE == cond.getType() || AttributeCond.Type.IEQ == cond.getType(); String column = (cond instanceof AnyCond) ? cond.getSchema() : svs.fieldName(schema.getType()); if ((schema.getType() == AttrSchemaType.String || schema.getType() == AttrSchemaType.Enum) && ignoreCase) { column = "LOWER (" + column + ")"; switch (cond.getType()) { query.append("LOWER(?").append(setParameter(parameters, cond.getExpression())).append(')'); } else { query.append('?').append(setParameter(parameters, cond.getExpression()));
|| "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema) ? new AnyCond() : new AttributeCond(); cond.setSchema(schema); cond.setType(type); cond.setExpression(expression);