update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
120
.config/Code/User/History/-79eaee52/0yin.java
Normal file
120
.config/Code/User/History/-79eaee52/0yin.java
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
108
.config/Code/User/History/-79eaee52/15oV.java
Normal file
108
.config/Code/User/History/-79eaee52/15oV.java
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/2V8X.java
Normal file
105
.config/Code/User/History/-79eaee52/2V8X.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
104
.config/Code/User/History/-79eaee52/6LfC.java
Normal file
104
.config/Code/User/History/-79eaee52/6LfC.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "ksclient7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
122
.config/Code/User/History/-79eaee52/6eES.java
Normal file
122
.config/Code/User/History/-79eaee52/6eES.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
auto a = client.sendAsync(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
109
.config/Code/User/History/-79eaee52/AyVn.java
Normal file
109
.config/Code/User/History/-79eaee52/AyVn.java
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
public static void init(){}
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/B8uT.java
Normal file
105
.config/Code/User/History/-79eaee52/B8uT.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
126
.config/Code/User/History/-79eaee52/CKBk.java
Normal file
126
.config/Code/User/History/-79eaee52/CKBk.java
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
127
.config/Code/User/History/-79eaee52/Cxus.java
Normal file
127
.config/Code/User/History/-79eaee52/Cxus.java
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String sendWarmupRequest(){
|
||||
try{
|
||||
String res;
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/Id2z.java
Normal file
105
.config/Code/User/History/-79eaee52/Id2z.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/JBRA.java
Normal file
105
.config/Code/User/History/-79eaee52/JBRA.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "ksclient7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "ksclient7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
127
.config/Code/User/History/-79eaee52/MBVp.java
Normal file
127
.config/Code/User/History/-79eaee52/MBVp.java
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String sendWarmupRequest(){
|
||||
try{
|
||||
String resp = null;
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
resp = res.body();
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
123
.config/Code/User/History/-79eaee52/NGsZ.java
Normal file
123
.config/Code/User/History/-79eaee52/NGsZ.java
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/PCrH.java
Normal file
105
.config/Code/User/History/-79eaee52/PCrH.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serverminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
101
.config/Code/User/History/-79eaee52/RAHS.java
Normal file
101
.config/Code/User/History/-79eaee52/RAHS.java
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "ksclient7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
115
.config/Code/User/History/-79eaee52/TU02.java
Normal file
115
.config/Code/User/History/-79eaee52/TU02.java
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri("https://rafayahmad.serveminecraft.net:25565/warmup")
|
||||
.GET()
|
||||
.build();
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/Vtbu.java
Normal file
105
.config/Code/User/History/-79eaee52/Vtbu.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
// KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
// kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
108
.config/Code/User/History/-79eaee52/ZPGO.java
Normal file
108
.config/Code/User/History/-79eaee52/ZPGO.java
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
112
.config/Code/User/History/-79eaee52/bhQO.java
Normal file
112
.config/Code/User/History/-79eaee52/bhQO.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
122
.config/Code/User/History/-79eaee52/cJN7.java
Normal file
122
.config/Code/User/History/-79eaee52/cJN7.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
108
.config/Code/User/History/-79eaee52/czTj.java
Normal file
108
.config/Code/User/History/-79eaee52/czTj.java
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/dAOd.java
Normal file
105
.config/Code/User/History/-79eaee52/dAOd.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/dW8O.java
Normal file
105
.config/Code/User/History/-79eaee52/dW8O.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
// KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
// kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
115
.config/Code/User/History/-79eaee52/dkBy.java
Normal file
115
.config/Code/User/History/-79eaee52/dkBy.java
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
1
.config/Code/User/History/-79eaee52/entries.json
Normal file
1
.config/Code/User/History/-79eaee52/entries.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/Java/hcloudclient/src/main/java/com/rutils/HttpsUtil.java","entries":[{"id":"RAHS.java","timestamp":1720853531297},{"id":"6LfC.java","timestamp":1720853751820},{"id":"JBRA.java","timestamp":1720853778443},{"id":"Id2z.java","timestamp":1720856871020},{"id":"PCrH.java","timestamp":1720857184168},{"id":"h0Wp.java","timestamp":1720857199054},{"id":"B8uT.java","timestamp":1720857440308},{"id":"Vtbu.java","timestamp":1720858081619},{"id":"dW8O.java","timestamp":1720858092482},{"id":"2V8X.java","timestamp":1720858104535},{"id":"dAOd.java","timestamp":1720858176092},{"id":"ZPGO.java","timestamp":1720861713326},{"id":"czTj.java","timestamp":1720861734559},{"id":"jmJb.java","timestamp":1720931293486},{"id":"AyVn.java","timestamp":1720931771994},{"id":"15oV.java","timestamp":1721206341990},{"id":"vpm2.java","source":"Create method 'sendWarmupRequest()' in type 'HttpsUtil'","timestamp":1721388071695},{"id":"bhQO.java","timestamp":1721388092716},{"id":"TU02.java","timestamp":1721388183434},{"id":"dkBy.java","timestamp":1721388203321},{"id":"0yin.java","timestamp":1721388216765},{"id":"cJN7.java","timestamp":1721388228698},{"id":"miu2.java","timestamp":1721388251305},{"id":"6eES.java","timestamp":1721388267286},{"id":"xb2l.java","source":"Change type of 'a' to 'CompletableFuture<HttpResponse<String>>'","timestamp":1721388300740},{"id":"NGsZ.java","timestamp":1721388305363},{"id":"mh7L.java","timestamp":1721388315507},{"id":"jW4p.java","timestamp":1721388404032},{"id":"hAe2.java","timestamp":1721388430929},{"id":"Cxus.java","timestamp":1721388462265},{"id":"MBVp.java","timestamp":1721388844184},{"id":"fnbs.java","timestamp":1721388869317},{"id":"CKBk.java","timestamp":1721390787009}]}
|
||||
127
.config/Code/User/History/-79eaee52/fnbs.java
Normal file
127
.config/Code/User/History/-79eaee52/fnbs.java
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String sendWarmupRequest(){
|
||||
String resp = null;
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
resp = res.body();
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
105
.config/Code/User/History/-79eaee52/h0Wp.java
Normal file
105
.config/Code/User/History/-79eaee52/h0Wp.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serverminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
126
.config/Code/User/History/-79eaee52/hAe2.java
Normal file
126
.config/Code/User/History/-79eaee52/hAe2.java
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
return res.body();
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
126
.config/Code/User/History/-79eaee52/jW4p.java
Normal file
126
.config/Code/User/History/-79eaee52/jW4p.java
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
response.thenAccept(res -> {
|
||||
|
||||
});
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
110
.config/Code/User/History/-79eaee52/jmJb.java
Normal file
110
.config/Code/User/History/-79eaee52/jmJb.java
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void init(){}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
124
.config/Code/User/History/-79eaee52/mh7L.java
Normal file
124
.config/Code/User/History/-79eaee52/mh7L.java
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> response = client.sendAsync(request, BodyHandlers.ofString());
|
||||
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
122
.config/Code/User/History/-79eaee52/miu2.java
Normal file
122
.config/Code/User/History/-79eaee52/miu2.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
client.sendAsync(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
113
.config/Code/User/History/-79eaee52/vpm2.java
Normal file
113
.config/Code/User/History/-79eaee52/vpm2.java
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'sendWarmupRequest'");
|
||||
}
|
||||
}
|
||||
123
.config/Code/User/History/-79eaee52/xb2l.java
Normal file
123
.config/Code/User/History/-79eaee52/xb2l.java
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
|
||||
public class HttpsUtil{
|
||||
|
||||
static HttpClient client;
|
||||
|
||||
static{
|
||||
try{
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(HttpsUtil.class.getClassLoader().getResourceAsStream("auth/ksclient.p12"), "client7548".toCharArray());
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(keyStore);
|
||||
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(keyStore, "client7548".toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.sslContext(sslContext)
|
||||
.build();
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendWarmupRequest(){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/warmup"))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
CompletableFuture<HttpResponse<String>> a = client.sendAsync(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int registerUser(String username, String password, String passwordAgain){
|
||||
if(password.equals(passwordAgain) && username.length() != 0 && password.length() != 0){
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int verifyCredentials(String username, String password){
|
||||
try{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://rafayahmad.serveminecraft.net:25565/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
int response = Integer.parseInt(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e){
|
||||
System.err.println("sending request interuppterd Eroor");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(IOException e){
|
||||
System.err.println("io exeception when sending http request");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue