Class IckleQueryOperators

java.lang.Object
org.keycloak.models.map.storage.hotRod.IckleQueryOperators

public class IckleQueryOperators extends Object
This class provides knowledge on how to build Ickle query where clauses for specified ModelCriteriaBuilder.Operator.

For example,

for operator ModelCriteriaBuilder.Operator.EQ we concatenate left operand and right operand with equal sign: fieldName = :parameterName

however, for operator ModelCriteriaBuilder.Operator.EXISTS we add following:

fieldName IS NOT NULL AND fieldName IS NOT EMPTY". For right side operands we use named parameters to avoid injection attacks. Mapping between named parameter and corresponding value is then saved into Map<String, Object> that is passed to each IckleQueryOperators.ExpressionCombinator.

  • Field Details

  • Constructor Details

    • IckleQueryOperators

      public IckleQueryOperators()
  • Method Details

    • findAvailableNamedParam

      public static String findAvailableNamedParam(Set<String> existingNames, String namePrefix)
      Maps namePrefix to next available parameter name. For example, if namePrefix == "id" and existingNames set already contains id0 and id1 it returns id2. Any character that is not an alphanumeric will be stripped, so that it works for prefixes like "attributes.name" as well. This method is used for computing available names for name query parameters. Instead of creating generic named parameters that would be hard to debug and read by humans, it creates readable named parameters from the prefix.
      Parameters:
      existingNames - set of parameter names that are already used in this Ickle query
      namePrefix - name of the parameter
      Returns:
      next available parameter name
    • combineExpressions

      public static String combineExpressions(ModelCriteriaBuilder.Operator op, String modelFieldName, Object[] values, Map<String,Object> parameters)
      Provides a string containing where clause for given operator, field name and values
      Parameters:
      op - operator
      modelFieldName - field name
      values - values
      parameters - mapping between named parameters and their values
      Returns:
      where clause