<code>
Generates a secured payload
</code>
@param customerId The customerId as seen in Command Center. Ensure this is not the subdomain, which can be `customerId-cors.groupbycloud.com`
@param query The query to encrypt
507298
public AesContent generateSecuredPayload(String customerId, Query query) throws GeneralSecurityException {
    return generateSecuredPayload(customerId, clientKey, query);
  }
288962
function(client, method, url, payload, query) {
  // Add query to url if present
  if (query) {
    query = querystring.stringify(query);
    if (query.length > 0) {
      url += '?' + query;
    }
  }

  // Construct request object
  var req = request(method.toUpperCase(), url);
  // Set the http agent for this request, if supported in the current
  // environment (browser environment doesn't support http.Agent)
  if (req.agent) {
    req.agent(client._httpAgent);
  }

  // Timeout for each individual request.
  req.timeout(client._timeout);

  // Send payload if defined
  if (payload !== undefined) {
    req.send(payload);
  }

  // Authenticate, if credentials are provided
  if (client._options.credentials &&
      client._options.credentials.clientId &&
      client._options.credentials.accessToken) {
    // Create hawk authentication header
    var header = hawk.client.header(url, method.toUpperCase(), {
      credentials: {
        id:         client._options.credentials.clientId,
        key:        client._options.credentials.accessToken,
        algorithm:  'sha256',
      },
      ext:          client._extData,
    });
    req.set('Authorization', header.field);
  }

  // Return request
  return req;
}
742760
def query(capability, action, data, priority = 30, instance_id = nil)
      query_message = {
        id: SecureRandom.uuid,
        capability: capability,
        action: action,
        data: data,
        priority: priority,
        instanceId: []
      }
      query_message[:instanceId] = instance_id unless instance_id.nil?

      send_message('MSG_QUERY', query_message)
    end
957111
protected function checkCsrf($id = 'lexik-translation', $query = '_token')
    {
        if (!$this->has('security.csrf.token_manager')) {
            return;
        }

        $request = $this->get('request_stack')->getCurrentRequest();

        if (!$this->isCsrfTokenValid($id, $request->get($query))) {
            throw $this->createAccessDeniedException('Invalid CSRF token');
        }
    }
259855
private QueryBuilderKraken parseMap(QueryBuilderKraken query)
  {
    boolean distinct = false;

    Token token = scanToken();

    if (token == Token.DISTINCT)
      distinct = true;
    else
      _token = token;

    ArrayList<ExprKraken> resultItems = new ArrayList<>();

    Token startToken = scanToken();
    String startLexeme = _lexeme;
    int startOffset = _parseIndex;

    while ((token = scanToken()) != null
        && token != Token.EOF 
        && token != Token.FROM) {
    }

    if (token != Token.FROM) { 
      throw error("expected FROM at '{0}'", token);
    }

    _query = query;

    String tableName = parseFrom();

    query.setTableName(tableName);
    
    token = scanToken();
    
    Token tailToken = token;
    int tailOffset = _parseIndex;

    _token = startToken;
    _parseIndex = startOffset;
    _lexeme = startLexeme;

    ExprKraken expr = parseSelectExpr();

    resultItems.add(expr);

    while ((token = scanToken()) == Token.COMMA) {
      expr = parseSelectExpr();

      resultItems.add(expr);
    }

    _token = tailToken;
    _parseIndex = tailOffset;

    token = scanToken();
    
    ExprKraken whereExpr = null;

    if (token == Token.WHERE) {
      // _andExpr.add(parseExpr());
      whereExpr = parseExpr();
    }
    else {
      _token = token;
    }

    ParamExpr []params = _params.toArray(new ParamExpr[_params.size()]);
    
    query.setWhereExpr(whereExpr);
    // query.setKelpExpr(whereKelp);
    query.setParams(params);

    for (int i = resultItems.size() - 1; i >= 0; i--) {
      ExprKraken subExpr = resultItems.get(i);
    }

    ExprKraken []resultArray
      = resultItems.toArray(new ExprKraken[resultItems.size()]);

    query.setResults(resultArray);
    
    token = scanToken();
    
    if (token != null 
        && token != Token.EOF
        && token != Token.LIMIT 
        && token != Token.OFFSET) {
      throw error("unexpected token at end '{0}'", token);
    }

    return query;
  }
824988
public void bindInstanceToSecurityGroup(BindSecurityGroupRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty.");
        checkStringNotEmpty(request.getSecurityGroupId(), "request securityGroupId should not be empty.");
        InternalRequest internalRequest = this.createRequest(
                request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId());
        internalRequest.addParameter(InstanceAction.bind.name(), null);
        fillPayload(internalRequest, request);
        this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
550743
public static String encodeQuery(String query) {
        if (query == null) {
            return null;
        }

        StringBuilder rebuiltQuery = new StringBuilder();

        // Encode parameters to mitigate XSS attacks
        String[] queryParams = query.split("&");
        for (String param : queryParams) {
            String rebuiltParam = encode(param);
            int equalIndex = param.indexOf("=");
            if (equalIndex > -1) {
                String name = param.substring(0, equalIndex);
                String value = (equalIndex < (param.length() - 1)) ? param.substring(equalIndex + 1) : "";
                rebuiltParam = encode(name) + "=" + encode(value);
            }
            if (!rebuiltParam.isEmpty()) {
                rebuiltQuery.append(rebuiltParam + "&");
            }
        }
        // Remove trailing '&' character
        if (rebuiltQuery.length() > 0 && rebuiltQuery.charAt(rebuiltQuery.length() - 1) == '&') {
            rebuiltQuery.deleteCharAt(rebuiltQuery.length() - 1);
        }
        return rebuiltQuery.toString();
    }
829660
public void configureExecutionQuery(AbstractQuery query) {
    configureQuery(query);
    CompositePermissionCheck permissionCheck = new PermissionCheckBuilder()
        .disjunctive()
        .atomicCheck(PROCESS_INSTANCE, "RES.PROC_INST_ID_", READ)
        .atomicCheck(PROCESS_DEFINITION, "P.KEY_", READ_INSTANCE)
        .build();
    addPermissionCheck(query.getAuthCheck(), permissionCheck);
  }
358716
protected <T extends SAMLObject> void prepareEndpointURLSchemeSecurityHandler(final MessageContext<T> outboundContext) throws Exception {
        val handlerEnd = new EndpointURLSchemeSecurityHandler();
        handlerEnd.initialize();
        handlerEnd.invoke(outboundContext);
    }
1085265
protected void configureVariableInstanceQuery(VariableInstanceQueryImpl query) {
    configureQuery(query);

    if(query.getAuthCheck().isAuthorizationCheckEnabled()) {

      CompositePermissionCheck permissionCheck;
      if (isEnsureSpecificVariablePermission()) {
        permissionCheck = new PermissionCheckBuilder()
            .disjunctive()
            .atomicCheck(PROCESS_DEFINITION, "PROCDEF.KEY_", READ_INSTANCE_VARIABLE)
            .atomicCheck(TASK, "RES.TASK_ID_", READ_VARIABLE)
            .build();
      } else {
        permissionCheck = new PermissionCheckBuilder()
              .disjunctive()
              .atomicCheck(PROCESS_INSTANCE, "RES.PROC_INST_ID_", READ)
              .atomicCheck(PROCESS_DEFINITION, "PROCDEF.KEY_", READ_INSTANCE)
              .atomicCheck(TASK, "RES.TASK_ID_", READ)
              .build();
      }
        addPermissionCheck(query.getAuthCheck(), permissionCheck);
    }
  }
328581
public void configureProcessDefinitionQuery(ProcessDefinitionQueryImpl query) {
    configureQuery(query, PROCESS_DEFINITION, "RES.KEY_");

    if (query.isStartablePermissionCheck()) {
      AuthorizationCheck authorizationCheck = query.getAuthCheck();

      if (!authorizationCheck.isRevokeAuthorizationCheckEnabled()) {
        CompositePermissionCheck permCheck = new PermissionCheckBuilder()
            .atomicCheck(PROCESS_DEFINITION, "RES.KEY_", Permissions.CREATE_INSTANCE)
            .build();

        query.addProcessDefinitionCreatePermissionCheck(permCheck);

      } else {
        CompositePermissionCheck permissionCheck = new PermissionCheckBuilder()
            .conjunctive()
            .atomicCheck(PROCESS_DEFINITION, "RES.KEY_", READ)
            .atomicCheck(PROCESS_DEFINITION, "RES.KEY_", Permissions.CREATE_INSTANCE)
            .build();
        addPermissionCheck(authorizationCheck, permissionCheck);
      }

    }

  }
106302
public static Map<String, String> parseQuery(String query) {
		Map<String, String> result = new LinkedHashMap<String, String>();
		
		if (query != null) {
			for (String keyValue: query.split("&")) {
				String[] pair = keyValue.split("=");
				result.put(StringUtils.urlDecode(pair[0]), StringUtils.urlDecode(pair[1]));
			}
		}
		
		return result;
	}
902317
private <T extends IEntity> IntuitMessage prepareQuery(String query) throws FMSException {
        IntuitMessage intuitMessage = new IntuitMessage();
        RequestElements requestElements = intuitMessage.getRequestElements();

        //set the request params
        Map<String, String> requestParameters = requestElements.getRequestParameters();
        if (query.length() > LENGTH_200) {
            requestParameters.put(RequestElements.REQ_PARAM_METHOD_TYPE, MethodType.POST.toString());
            requestElements.setPostString(query);
        } else {
            requestParameters.put(RequestElements.REQ_PARAM_METHOD_TYPE, MethodType.GET.toString());
            requestParameters.put(RequestElements.REQ_PARAM_QUERY, query);
        }

        requestElements.setAction(OperationType.QUERY.toString());
        requestElements.setContext(context);

        return intuitMessage;
    }
205473
protected function _findEncryptedFilterData(Query $query, ServerRequest $request)
    {
        return $query
            ->select($this->getAlias() . '.filter_data')
            ->where([
                $this->getAlias() . '.controller' => $request->getParam('controller'),
                $this->getAlias() . '.action' => $request->getParam('action'),
                $this->getAlias() . '.slug' => $request->getParam('sluggedFilter')
            ])
            ->where($this->_pluginCondition($request));
    }
448117
private String _serializeQuery(Query query, Map<Object, String> done, String id) throws ConverterException {

	/*
	 * <QUERY ID="1"> <COLUMNNAMES> <COLUMN NAME="a"></COLUMN> <COLUMN NAME="b"></COLUMN> </COLUMNNAMES>
	 * 
	 * <ROWS> <ROW> <COLUMN TYPE="STRING">a1</COLUMN> <COLUMN TYPE="STRING">b1</COLUMN> </ROW> <ROW>
	 * <COLUMN TYPE="STRING">a2</COLUMN> <COLUMN TYPE="STRING">b2</COLUMN> </ROW> </ROWS> </QUERY>
	 */
	Collection.Key[] keys = CollectionUtil.keys(query);
	StringBuilder sb = new StringBuilder(goIn() + "<QUERY ID=\"" + id + "\">");

	// columns
	sb.append(goIn() + "<COLUMNNAMES>");
	for (int i = 0; i < keys.length; i++) {
	    sb.append(goIn() + "<COLUMN NAME=\"" + keys[i].getString() + "\"></COLUMN>");
	}
	sb.append(goIn() + "</COLUMNNAMES>");

	String value;
	deep++;
	sb.append(goIn() + "<ROWS>");
	int len = query.getRecordcount();
	for (int row = 1; row <= len; row++) {
	    sb.append(goIn() + "<ROW>");
	    for (int col = 0; col < keys.length; col++) {
		try {
		    value = _serialize(query.getAt(keys[col], row), done);
		}
		catch (PageException e) {
		    value = _serialize(e.getMessage(), done);
		}
		sb.append("<COLUMN TYPE=\"" + type + "\">" + value + "</COLUMN>");
	    }
	    sb.append(goIn() + "</ROW>");

	}
	sb.append(goIn() + "</ROWS>");
	deep--;

	sb.append(goIn() + "</QUERY>");
	type = "QUERY";
	return sb.toString();
    }
894289
public static ByteBuf createDnsQueryPayload(DnsTransaction transaction) {
		ByteBuf byteBuf = ByteBufPool.allocate(MAX_SIZE);

		byteBuf.writeShort(transaction.getId());
		// standard query flags, 1 question and 0 of other stuff
		byteBuf.write(STANDARD_QUERY_HEADER);

		// query domain name
		byte componentSize = 0;
		DnsQuery query = transaction.getQuery();
		byte[] domainBytes = query.getDomainName().getBytes(US_ASCII);

		int pos = -1;
		while (++pos < domainBytes.length) {
			if (domainBytes[pos] != '.') {
				componentSize++;
				continue;
			}
			byteBuf.writeByte(componentSize);
			byteBuf.write(domainBytes, pos - componentSize, componentSize);
			componentSize = 0;
		}
		byteBuf.writeByte(componentSize);
		byteBuf.write(domainBytes, pos - componentSize, componentSize);
		byteBuf.writeByte((byte) 0x0); // terminator byte

		// query record type
		byteBuf.writeShort(query.getRecordType().getCode());
		// query class: IN
		byteBuf.writeShort(QueryClass.INTERNET.getCode());
		return byteBuf;
	}
300979
@Override
	public ConstrainedResultSet<ID> findIdsByUriQuery(final WebQuery query)
	{
		return (ConstrainedResultSet<ID>) find(query, JPASearchStrategy.ID);
	}