proxy progress - I am getting tired :(
This commit is contained in:
parent
972db27d40
commit
86f23b20b7
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi.server;
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import com.rusefi.tools.online.HttpUtil;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
@ -34,13 +35,7 @@ public class ApplicationRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationRequest valueOf(String jsonString) {
|
public static ApplicationRequest valueOf(String jsonString) {
|
||||||
JSONParser parser = new JSONParser();
|
JSONObject jsonObject = HttpUtil.parse(jsonString);
|
||||||
JSONObject jsonObject;
|
|
||||||
try {
|
|
||||||
jsonObject = (JSONObject) parser.parse(jsonString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
long targetUserId = (Long) jsonObject.get(USER_ID);
|
long targetUserId = (Long) jsonObject.get(USER_ID);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi.server;
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import com.rusefi.tools.online.HttpUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
|
@ -60,13 +61,7 @@ public class ControllerInfo {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ControllerInfo valueOf(String jsonString) {
|
public static ControllerInfo valueOf(String jsonString) {
|
||||||
JSONParser parser = new JSONParser();
|
JSONObject jsonObject = HttpUtil.parse(jsonString);
|
||||||
JSONObject jsonObject;
|
|
||||||
try {
|
|
||||||
jsonObject = (JSONObject) parser.parse(jsonString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
return valueOf(jsonObject);
|
return valueOf(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import com.rusefi.tools.online.HttpUtil;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class ControllerStateDetails {
|
||||||
|
public static final String RPM = "RPM";
|
||||||
|
public static final String CLT = "CLT";
|
||||||
|
private final double clt;
|
||||||
|
private final int rpm;
|
||||||
|
|
||||||
|
public ControllerStateDetails(double clt, int rpm) {
|
||||||
|
this.clt = clt;
|
||||||
|
this.rpm = rpm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getClt() {
|
||||||
|
return clt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRpm() {
|
||||||
|
return rpm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ControllerStateDetails valueOf(String jsonString) {
|
||||||
|
JSONObject jsonObject = HttpUtil.parse(jsonString);
|
||||||
|
double clt = Double.parseDouble((String) jsonObject.get(CLT));
|
||||||
|
int rpm = Integer.parseInt((String) jsonObject.get(RPM));
|
||||||
|
|
||||||
|
return new ControllerStateDetails(clt, rpm);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,14 @@
|
||||||
package com.rusefi.server;
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import com.rusefi.tools.online.HttpUtil;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A session from Controller, including some sensitive information
|
||||||
|
*/
|
||||||
public class SessionDetails {
|
public class SessionDetails {
|
||||||
private static final String ONE_TIME_TOKEN = "oneTime";
|
private static final String ONE_TIME_TOKEN = "oneTime";
|
||||||
private static final String AUTH_TOKEN = "authToken";
|
private static final String AUTH_TOKEN = "authToken";
|
||||||
|
@ -51,13 +53,7 @@ public class SessionDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SessionDetails valueOf(String jsonString) {
|
public static SessionDetails valueOf(String jsonString) {
|
||||||
JSONParser parser = new JSONParser();
|
JSONObject jsonObject = HttpUtil.parse(jsonString);
|
||||||
JSONObject jsonObject;
|
|
||||||
try {
|
|
||||||
jsonObject = (JSONObject) parser.parse(jsonString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
String authToken = (String) jsonObject.get(AUTH_TOKEN);
|
String authToken = (String) jsonObject.get(AUTH_TOKEN);
|
||||||
long oneTimeCode = (Long)jsonObject.get(ONE_TIME_TOKEN);
|
long oneTimeCode = (Long)jsonObject.get(ONE_TIME_TOKEN);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
@ -42,4 +43,15 @@ public class HttpUtil {
|
||||||
HttpGet httpget = new HttpGet(url);
|
HttpGet httpget = new HttpGet(url);
|
||||||
return httpclient.execute(httpget);
|
return httpclient.execute(httpget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JSONObject parse(String jsonString) {
|
||||||
|
JSONParser parser = new JSONParser();
|
||||||
|
JSONObject jsonObject;
|
||||||
|
try {
|
||||||
|
jsonObject = (JSONObject) parser.parse(jsonString);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,8 +268,8 @@ public class Backend implements Closeable {
|
||||||
.add(UserDetails.USER_ID, client.getUserDetails().getUserId())
|
.add(UserDetails.USER_ID, client.getUserDetails().getUserId())
|
||||||
.add(UserDetails.USERNAME, client.getUserDetails().getUserName())
|
.add(UserDetails.USERNAME, client.getUserDetails().getUserName())
|
||||||
.add(IS_USED, client.getTwoKindSemaphore().isUsed())
|
.add(IS_USED, client.getTwoKindSemaphore().isUsed())
|
||||||
.add("RPM", rpm)
|
.add(ControllerStateDetails.RPM, rpm)
|
||||||
.add("CLT", clt)
|
.add(ControllerStateDetails.CLT, clt)
|
||||||
.add(ControllerInfo.SIGNATURE, client.getSessionDetails().getControllerInfo().getSignature())
|
.add(ControllerInfo.SIGNATURE, client.getSessionDetails().getControllerInfo().getSignature())
|
||||||
.add(ControllerInfo.VEHICLE_NAME, client.getSessionDetails().getControllerInfo().getVehicleName())
|
.add(ControllerInfo.VEHICLE_NAME, client.getSessionDetails().getControllerInfo().getVehicleName())
|
||||||
.add(ControllerInfo.ENGINE_MAKE, client.getSessionDetails().getControllerInfo().getEngineMake())
|
.add(ControllerInfo.ENGINE_MAKE, client.getSessionDetails().getControllerInfo().getEngineMake())
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class RemoteTab {
|
||||||
private final JComponent content = new JPanel(new BorderLayout());
|
private final JComponent content = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
private final JPanel list = new JPanel(new VerticalFlowLayout());
|
private final JPanel list = new JPanel(new VerticalFlowLayout());
|
||||||
|
private final JTextField oneTimePasswordControl = new JTextField();
|
||||||
|
|
||||||
private final Executor listDownloadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("online list downloader"));
|
private final Executor listDownloadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("online list downloader"));
|
||||||
|
|
||||||
|
@ -42,8 +43,10 @@ public class RemoteTab {
|
||||||
|
|
||||||
JPanel topPanel = new JPanel(new FlowLayout());
|
JPanel topPanel = new JPanel(new FlowLayout());
|
||||||
topPanel.add(refresh);
|
topPanel.add(refresh);
|
||||||
topPanel.add(new JLabel("Local Port"));
|
topPanel.add(new JLabel(" Local Port: "));
|
||||||
topPanel.add(applicationPort);
|
topPanel.add(applicationPort);
|
||||||
|
topPanel.add(new JLabel(" One time password:"));
|
||||||
|
topPanel.add(oneTimePasswordControl);
|
||||||
content.add(topPanel, BorderLayout.NORTH);
|
content.add(topPanel, BorderLayout.NORTH);
|
||||||
content.add(list, BorderLayout.CENTER);
|
content.add(list, BorderLayout.CENTER);
|
||||||
requestListDownload();
|
requestListDownload();
|
||||||
|
@ -89,7 +92,7 @@ public class RemoteTab {
|
||||||
userPanel.add(new URLLabel(SignatureHelper.getUrl(controllerInfo.getSignature())));
|
userPanel.add(new URLLabel(SignatureHelper.getUrl(controllerInfo.getSignature())));
|
||||||
|
|
||||||
|
|
||||||
|
userPanel.add(new JButton("Connect"));
|
||||||
|
|
||||||
return userPanel;
|
return userPanel;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue