Good day!
For example, when a server requests a "... / get.php" address, it receives a set of data, let it be a certain array [1,2,3]. On the client, by pressing the buttons, this array changes, naturally within the framework of the algorithm in the handlers. And then when you click the Save button, the new array [4,5,6] is sent to the "... / set.php" HTTp POST request with parameters = new array or json'om.
Question: Is it possible to spoof the data in the HTTP POST request or json sent to the server? Those. Can a registered user send his "own" data (for example, array [10,13,1]) to "... / set.php" and how to protect against this?
RequestBuilder is used for requests in GWT.
String url = "http://xxx.xxx/get.php"; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url)); try { Request request = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { // Couldn't connect to server (could be timeout, SOP violation, etc.) } public void onResponseReceived(Request request, Response response) { if (Response.SC_OK == response.getStatusCode()) { // Парсим JSON и отображаем данные клиенту } }}} // Далее, после того как пользователь понажимал кнопки, // нужно отправить новый массив обратно в базу String url = "http://xxx.xxx/set.php"; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url); builder.setHeader("Content-type", "application/x-www-form-urlencoded"); StringBuilder sb = new StringBuilder(); for ( String k: parmsRequest.keySet() ) { String vx = URL.encodeComponent( parmsRequest.get(k)); if ( sb.length() > 0 ) { sb.append("&"); } sb.append(k).append("=").append(vx); } try { Request response = builder.sendRequest( sb.toString(), new RequestCallback() { public void onError(Request request, Throwable exception) {} public void onResponseReceived(Request request, Response response) {} }); } catch (RequestException e) {}