Ajout de la gestion des SSL invalides
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
bin/
|
bin/
|
||||||
|
out/
|
||||||
|
|||||||
25
.idea/workspace.xml
generated
25
.idea/workspace.xml
generated
@@ -2,23 +2,21 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ArtifactsWorkspaceSettings">
|
<component name="ArtifactsWorkspaceSettings">
|
||||||
<artifacts-to-build>
|
<artifacts-to-build>
|
||||||
<artifact name="Release" />
|
<artifact name="cURLing:jar" />
|
||||||
</artifacts-to-build>
|
</artifacts-to-build>
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e7334e23-5435-4e6d-8822-56d062382d3d" name="Default Changelist" comment="">
|
<list default="true" id="e7334e23-5435-4e6d-8822-56d062382d3d" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/dataSet/HeaderModel.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/web/Client.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/web/Method.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/web/RequestError.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/cURLing.iml" beforeDir="false" afterPath="$PROJECT_DIR$/cURLing.iml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/Runtime.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/Runtime.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/AddHeader.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/AddHeader.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/web/Client$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/web/Client$1.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/BasicAuthenticationDialog.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/BasicAuthenticationDialog.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/web/Client.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/web/Client.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/MainWindow$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/MainWindow$1.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/MainWindow.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/ovh/alexisdelhaie/curling/windows/MainWindow.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/Runtime.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/Runtime.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/web/Client.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/web/Client.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/FormEncodedDialog.form" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.form" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.form" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ovh/alexisdelhaie/curling/windows/MainWindow.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
<property name="GenerateAntBuildDialog.generateSingleFile" value="true" />
|
<property name="GenerateAntBuildDialog.generateSingleFile" value="true" />
|
||||||
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="curling" />
|
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="curling" />
|
||||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||||
|
<property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.SHOW" value="true" />
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="aspect.path.notification.shown" value="true" />
|
<property name="aspect.path.notification.shown" value="true" />
|
||||||
<property name="last_opened_file_path" value="$USER_HOME$/IdeaProjects" />
|
<property name="last_opened_file_path" value="$USER_HOME$/IdeaProjects" />
|
||||||
@@ -103,6 +102,8 @@
|
|||||||
<workItem from="1571255923711" duration="810000" />
|
<workItem from="1571255923711" duration="810000" />
|
||||||
<workItem from="1571330910099" duration="9724000" />
|
<workItem from="1571330910099" duration="9724000" />
|
||||||
<workItem from="1571341924674" duration="72000" />
|
<workItem from="1571341924674" duration="72000" />
|
||||||
|
<workItem from="1571416842970" duration="388000" />
|
||||||
|
<workItem from="1571509954096" duration="5286000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Main-Class: ovh.alexisdelhaie.curling.Runtime
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,24 @@
|
|||||||
package ovh.alexisdelhaie.curling;
|
package ovh.alexisdelhaie.curling;
|
||||||
|
|
||||||
import ovh.alexisdelhaie.curling.windows.MainWindow;
|
import ovh.alexisdelhaie.curling.windows.MainWindow;
|
||||||
|
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Runtime {
|
public class Runtime {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
Logger.getGlobal().warning(e.getMessage());
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Logger.getGlobal().warning(e.getMessage());
|
||||||
|
} catch (UnsupportedLookAndFeelException e) {
|
||||||
|
Logger.getGlobal().warning(e.getMessage());
|
||||||
|
}
|
||||||
MainWindow window = new MainWindow();
|
MainWindow window = new MainWindow();
|
||||||
window.showFrame();
|
window.showFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,32 @@
|
|||||||
package ovh.alexisdelhaie.curling.web;
|
package ovh.alexisdelhaie.curling.web;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.net.ssl.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
|
|
||||||
|
public static long TIMEOUT = 10000;
|
||||||
|
|
||||||
private String body;
|
private String body;
|
||||||
private Map<String, String> headers;
|
private Map<String, String> headers;
|
||||||
private Method method;
|
private Method method;
|
||||||
private String url;
|
private String url;
|
||||||
|
private long timeout;
|
||||||
|
private boolean allowInvalidSSL;
|
||||||
private RequestError error;
|
private RequestError error;
|
||||||
|
|
||||||
private String log;
|
private String log;
|
||||||
@@ -58,17 +68,26 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Client(String body, Map<String, String> headers, Method method, String url) {
|
public Client(String body, Map<String, String> headers, Method method, String url) {
|
||||||
|
this(body, headers, method, url, false, TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Client(String body, Map<String, String> headers, Method method, String url, boolean allowInvalidSSL) {
|
||||||
|
this(body, headers, method, url, allowInvalidSSL, TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Client(String body, Map<String, String> headers, Method method, String url, boolean allowInvalidSSL, long timeout) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
this.timeout = timeout;
|
||||||
|
this.allowInvalidSSL = allowInvalidSSL;
|
||||||
this.log = "";
|
this.log = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<String> run() {
|
public CompletableFuture<String> run() {
|
||||||
|
|
||||||
HttpClient httpClient = HttpClient.newBuilder().build();
|
|
||||||
try {
|
try {
|
||||||
|
HttpClient httpClient = getClient();
|
||||||
HttpRequest request = requestBuilder();
|
HttpRequest request = requestBuilder();
|
||||||
|
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
@@ -86,9 +105,11 @@ public class Client {
|
|||||||
}
|
}
|
||||||
result += String.format("\n%s", (String)r.body());
|
result += String.format("\n%s", (String)r.body());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
result += String.format("\n/!\\ %s", e.getMessage());
|
||||||
|
error = new RequestError(e.getMessage(), e.getLocalizedMessage(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
result += String.format("\n/!\\ %s", e.getMessage());
|
||||||
|
error = new RequestError("Thread interrupted", "The action was stopped (by you maybe)", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -100,6 +121,10 @@ public class Client {
|
|||||||
|
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
error = new RequestError("URL invalide", "Le format de l'URL est invalide", e);
|
error = new RequestError("URL invalide", "Le format de l'URL est invalide", e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -123,6 +148,31 @@ public class Client {
|
|||||||
if(method == Method.POST || method == Method.PUT) {
|
if(method == Method.POST || method == Method.PUT) {
|
||||||
log += String.format("%s", body);
|
log += String.format("%s", body);
|
||||||
}
|
}
|
||||||
|
b.timeout(Duration.ofMillis(timeout));
|
||||||
return b.build();
|
return b.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HttpClient getClient() throws KeyManagementException, NoSuchAlgorithmException {
|
||||||
|
HttpClient.Builder b = HttpClient.newBuilder();
|
||||||
|
b.followRedirects(HttpClient.Redirect.NEVER);
|
||||||
|
b.version(HttpClient.Version.HTTP_2);
|
||||||
|
if(allowInvalidSSL) {
|
||||||
|
b.sslContext(getInvalidSSLConfig());
|
||||||
|
}
|
||||||
|
return b.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SSLContext getInvalidSSLConfig() throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
|
new X509TrustManager() {
|
||||||
|
public java.security.cert.X509Certificate[] getAcceptedIssuers() {return null;}
|
||||||
|
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType){}
|
||||||
|
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType){}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
|
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,14 +104,6 @@
|
|||||||
<text value="Content"/>
|
<text value="Content"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="328a" class="javax.swing.JTextArea" binding="valueField">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
|
||||||
<preferred-size width="150" height="50"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
<component id="3fe5d" class="javax.swing.JComboBox" binding="encodageField">
|
<component id="3fe5d" class="javax.swing.JComboBox" binding="encodageField">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
@@ -123,6 +115,19 @@
|
|||||||
</model>
|
</model>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<scrollpane id="62efa">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="ac535" class="javax.swing.JTextArea" binding="valueField">
|
||||||
|
<constraints/>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</scrollpane>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,24 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ovh.alexisdelhaie.curling.windows.MainWindow">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ovh.alexisdelhaie.curling.windows.MainWindow">
|
||||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="10" left="10" bottom="10" right="10"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="48" y="54" width="739" height="412"/>
|
<xy x="48" y="54" width="1120" height="412"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none" title="cURLing"/>
|
<border type="none" title="cURLing"/>
|
||||||
<children>
|
<children>
|
||||||
<component id="b4b69" class="javax.swing.JComboBox" binding="httpTypeBox">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<model>
|
|
||||||
<item value="HTTP"/>
|
|
||||||
<item value="HTTPS"/>
|
|
||||||
</model>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="dc7ca" class="javax.swing.JComboBox" binding="methodBox">
|
<component id="dc7ca" class="javax.swing.JComboBox" binding="methodBox">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
@@ -32,17 +21,9 @@
|
|||||||
</model>
|
</model>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="3d00f" class="javax.swing.JTextField" binding="urlField">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
|
||||||
<preferred-size width="150" height="-1"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
<component id="adde4" class="javax.swing.JLabel">
|
<component id="adde4" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Custom headers"/>
|
<text value="Custom headers"/>
|
||||||
@@ -50,48 +31,15 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="1286d" class="javax.swing.JLabel">
|
<component id="1286d" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Body datas"/>
|
<text value="Body datas"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="627e7" class="javax.swing.JButton" binding="xFormEncodedButton" default-binding="true">
|
|
||||||
<constraints>
|
|
||||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<label value="Add X-form-encoded values"/>
|
|
||||||
<text value="Add X-form-encoded values"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="10f69" class="javax.swing.JProgressBar" binding="progressBar1" default-binding="true">
|
|
||||||
<constraints>
|
|
||||||
<grid row="5" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
<component id="76150" class="javax.swing.JButton" binding="newHeaderButton">
|
|
||||||
<constraints>
|
|
||||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<label value="New header"/>
|
|
||||||
<text value="New header"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="3d3b2" class="javax.swing.JButton" binding="addAuthButton">
|
|
||||||
<constraints>
|
|
||||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<label value="Basic authentication"/>
|
|
||||||
<text value="Basic authentication"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<scrollpane id="4befb">
|
<scrollpane id="4befb">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="0" row-span="1" col-span="4" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@@ -104,7 +52,7 @@
|
|||||||
</scrollpane>
|
</scrollpane>
|
||||||
<scrollpane id="cdcdf">
|
<scrollpane id="cdcdf">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="4" column="0" row-span="2" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="5" column="0" row-span="2" col-span="4" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@@ -115,19 +63,9 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
<component id="c866d" class="javax.swing.JButton" binding="runButton">
|
|
||||||
<constraints>
|
|
||||||
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<enabled value="true"/>
|
|
||||||
<label value="Start"/>
|
|
||||||
<text value="Start"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<scrollpane id="1b18">
|
<scrollpane id="1b18">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="3" row-span="5" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="4" row-span="6" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@@ -141,6 +79,115 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
|
<grid id="815c" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="282" height="34"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="b4b69" class="javax.swing.JComboBox" binding="httpTypeBox">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<model>
|
||||||
|
<item value="HTTP"/>
|
||||||
|
<item value="HTTPS"/>
|
||||||
|
</model>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="3d00f" class="javax.swing.JTextField" binding="urlField">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="254" height="30"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<grid id="37c3f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="c866d" class="javax.swing.JButton" binding="runButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<enabled value="true"/>
|
||||||
|
<label value="Start"/>
|
||||||
|
<text value="Start"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="10f69" class="javax.swing.JProgressBar" binding="progressBar1" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<grid id="a2fab" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="76150" class="javax.swing.JButton" binding="newHeaderButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<label value="New header"/>
|
||||||
|
<text value="New header"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="3d3b2" class="javax.swing.JButton" binding="addAuthButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="329" height="30"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<label value="Basic authentication"/>
|
||||||
|
<text value="Basic authentication"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<component id="627e7" class="javax.swing.JButton" binding="xFormEncodedButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="329" height="30"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<label value="Add X-form-encoded values"/>
|
||||||
|
<text value="Add X-form-encoded values"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="adccd" class="javax.swing.JCheckBox" binding="allowInvalidSSLField">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="329" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<enabled value="false"/>
|
||||||
|
<text value="Allow invalid SSL certificate"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import ovh.alexisdelhaie.curling.web.Method;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -33,14 +35,17 @@ public class MainWindow extends JDialog {
|
|||||||
private JButton newHeaderButton;
|
private JButton newHeaderButton;
|
||||||
private JButton addAuthButton;
|
private JButton addAuthButton;
|
||||||
private JButton runButton;
|
private JButton runButton;
|
||||||
|
private JCheckBox allowInvalidSSLField;
|
||||||
|
|
||||||
private DefaultListModel<String> model;
|
private DefaultListModel<String> model;
|
||||||
private Map<String, String> headers;
|
private Map<String, String> headers;
|
||||||
private Map<String, String> params;
|
private Map<String, String> params;
|
||||||
|
private boolean allowInvalidSSL;
|
||||||
|
|
||||||
public MainWindow() {
|
public MainWindow() {
|
||||||
super((Dialog) null);
|
super((Dialog) null);
|
||||||
setTitle(WINDOW_TITLE);
|
setTitle(WINDOW_TITLE);
|
||||||
|
allowInvalidSSL = false;
|
||||||
headers = new HashMap<>();
|
headers = new HashMap<>();
|
||||||
model = new DefaultListModel<>();
|
model = new DefaultListModel<>();
|
||||||
list1.setModel(model);
|
list1.setModel(model);
|
||||||
@@ -49,6 +54,14 @@ public class MainWindow extends JDialog {
|
|||||||
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
|
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
httpTypeBox.addActionListener((event) -> {
|
||||||
|
allowInvalidSSLField.setEnabled(httpTypeBox.getSelectedItem().equals("HTTPS"));
|
||||||
|
});
|
||||||
|
|
||||||
|
allowInvalidSSLField.addItemListener((event) -> {
|
||||||
|
allowInvalidSSL = (event.getStateChange() == ItemEvent.SELECTED);
|
||||||
|
});
|
||||||
|
|
||||||
newHeaderButton.addActionListener((event) -> {
|
newHeaderButton.addActionListener((event) -> {
|
||||||
AddHeader ah = new AddHeader();
|
AddHeader ah = new AddHeader();
|
||||||
HeaderModel h = ah.getValue();
|
HeaderModel h = ah.getValue();
|
||||||
@@ -92,7 +105,7 @@ public class MainWindow extends JDialog {
|
|||||||
|
|
||||||
private void start(ActionEvent ev) {
|
private void start(ActionEvent ev) {
|
||||||
startLoading(true);
|
startLoading(true);
|
||||||
Client c = new Client(bodyArea.getText(), headers, getMethod(), urlBuilder());
|
Client c = new Client(bodyArea.getText(), headers, getMethod(), urlBuilder(), getAllowInvalidSSL());
|
||||||
CompletableFuture<String> f = c.run();
|
CompletableFuture<String> f = c.run();
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -137,6 +150,15 @@ public class MainWindow extends JDialog {
|
|||||||
newHeaderButton.setEnabled(!b);
|
newHeaderButton.setEnabled(!b);
|
||||||
addAuthButton.setEnabled(!b);
|
addAuthButton.setEnabled(!b);
|
||||||
runButton.setEnabled(!b);
|
runButton.setEnabled(!b);
|
||||||
|
allowInvalidSSLField.setEnabled(!b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getAllowInvalidSSL() {
|
||||||
|
if(httpTypeBox.getSelectedItem().equals("HTTPS")) {
|
||||||
|
return allowInvalidSSL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLoading(boolean b) {
|
private void startLoading(boolean b) {
|
||||||
|
|||||||
Reference in New Issue
Block a user