mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 20:17:42 +01:00
Got something working on Edge.
This commit is contained in:
parent
6e821c8899
commit
ce4bb0836d
@ -138,4 +138,13 @@ public class Request implements Closeable {
|
||||
public void close() throws IOException {
|
||||
close.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Request{" +
|
||||
"request='" + request + '\'' +
|
||||
", target='" + target + '\'' +
|
||||
", authorization='" + authorization + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -98,25 +98,25 @@ public class WebSocketServer {
|
||||
trustManagerFactory.init(keystore);
|
||||
|
||||
server = HttpsServer.create(new InetSocketAddress(PORT), 10);
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
|
||||
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(keyManagerFactory.getKeyManagers(), null/*trustManagerFactory.getTrustManagers()*/, null);
|
||||
|
||||
((HttpsServer) server).setHttpsConfigurator(new HttpsConfigurator(sslContext) {
|
||||
public void configure(HttpsParameters params) {
|
||||
try {
|
||||
SSLContext c = SSLContext.getDefault();
|
||||
SSLEngine engine = c.createSSLEngine();
|
||||
// try {
|
||||
// SSLContext c = SSLContext.getDefault();
|
||||
SSLEngine engine = sslContext.createSSLEngine();
|
||||
|
||||
params.setNeedClientAuth(false);
|
||||
params.setCipherSuites(engine.getEnabledCipherSuites());
|
||||
params.setProtocols(engine.getEnabledProtocols());
|
||||
|
||||
SSLParameters defaultSSLParameters = c.getDefaultSSLParameters();
|
||||
SSLParameters defaultSSLParameters = sslContext.getDefaultSSLParameters();
|
||||
params.setSSLParameters(defaultSSLParameters);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.error("WebServer: SSL Engine loading Failed.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
// } catch (NoSuchAlgorithmException e) {
|
||||
// Log.error("WebServer: SSL Engine loading Failed.");
|
||||
// Log.toLog(this.getClass().getName(), e);
|
||||
// }
|
||||
}
|
||||
});
|
||||
startSuccessful = true;
|
||||
@ -127,16 +127,21 @@ public class WebSocketServer {
|
||||
Log.error("WebServer: SSL Context Initialization Failed.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.error("!--------!---------!---------!");
|
||||
Log.error("WebServer: SSL Certificate KeyStore File not Found: " + keyStorePath);
|
||||
Log.error("!--------!---------!---------!");
|
||||
} catch (KeyStoreException | CertificateException | UnrecoverableKeyException e) {
|
||||
Log.error("WebServer: SSL Certificate loading Failed.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
|
||||
Log.debug("Start Successful: "+startSuccessful);
|
||||
|
||||
if (!startSuccessful) {
|
||||
return; // TODO Http Server
|
||||
}
|
||||
|
||||
Log.debug("Create server context");
|
||||
server.createContext("/", serverResponse(null));
|
||||
HttpContext analysisPage = server.createContext("/server", serverResponse(null));
|
||||
HttpContext playersPage = server.createContext("/players", new PlayersPageResponse(null, plugin));
|
||||
|
@ -1,8 +1,11 @@
|
||||
package main.java.com.djrapitops.plan.ui.webserver.response;
|
||||
|
||||
import com.sun.net.httpserver.Headers;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpsExchange;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.Request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -57,10 +60,19 @@ public abstract class Response implements HttpHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
public void handle(HttpExchange xghng) throws IOException {
|
||||
Log.debug("Recieved HTTP Exchange");
|
||||
Log.debug(xghng.toString());
|
||||
HttpsExchange exchange = (HttpsExchange) xghng;
|
||||
try {
|
||||
exchange.sendResponseHeaders(getCode(), content.length());
|
||||
Headers headers = exchange.getRequestHeaders();
|
||||
Request req = new Request(exchange.getRequestBody());
|
||||
Log.debug(req.toString());
|
||||
// headers.set("Content-Type", "text/html");
|
||||
|
||||
exchange.sendResponseHeaders(getCode(), content.length());
|
||||
Log.debug("Content:");
|
||||
Log.debug(content);
|
||||
OutputStream os = exchange.getResponseBody();
|
||||
os.write(content.getBytes());
|
||||
os.close();
|
||||
|
Loading…
Reference in New Issue
Block a user