update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
100
.config/Code/User/History/3ebedc2c/0RVB.java
Normal file
100
.config/Code/User/History/3ebedc2c/0RVB.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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> response = client.send(request, BodyHandlers.ofString());
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
61
.config/Code/User/History/3ebedc2c/1FUH.java
Normal file
61
.config/Code/User/History/3ebedc2c/1FUH.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package com.rutils;
|
||||
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
102
.config/Code/User/History/3ebedc2c/3XuQ.java
Normal file
102
.config/Code/User/History/3ebedc2c/3XuQ.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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> response = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
66
.config/Code/User/History/3ebedc2c/45ez.java
Normal file
66
.config/Code/User/History/3ebedc2c/45ez.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
81
.config/Code/User/History/3ebedc2c/7xBM.java
Normal file
81
.config/Code/User/History/3ebedc2c/7xBM.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
66
.config/Code/User/History/3ebedc2c/9k3R.java
Normal file
66
.config/Code/User/History/3ebedc2c/9k3R.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
48
.config/Code/User/History/3ebedc2c/CM6G.java
Normal file
48
.config/Code/User/History/3ebedc2c/CM6G.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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;
|
||||
|
||||
public static void init(){
|
||||
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 void sendHttpsReq(HttpRequest request){
|
||||
try{
|
||||
client.send(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
49
.config/Code/User/History/3ebedc2c/DqWf.java
Normal file
49
.config/Code/User/History/3ebedc2c/DqWf.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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;
|
||||
|
||||
public static void init(){
|
||||
|
||||
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 void sendHttpsReq(HttpRequest request){
|
||||
try{
|
||||
client.send(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
94
.config/Code/User/History/3ebedc2c/Dr2z.java
Normal file
94
.config/Code/User/History/3ebedc2c/Dr2z.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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> response = client.send(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(URISyntaxException 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;
|
||||
}
|
||||
}
|
103
.config/Code/User/History/3ebedc2c/EeZu.java
Normal file
103
.config/Code/User/History/3ebedc2c/EeZu.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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;
|
||||
}
|
||||
}
|
71
.config/Code/User/History/3ebedc2c/Frfy.java
Normal file
71
.config/Code/User/History/3ebedc2c/Frfy.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
System.err.println("");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
catch(IOException e3){
|
||||
e3.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
72
.config/Code/User/History/3ebedc2c/Fva6.java
Normal file
72
.config/Code/User/History/3ebedc2c/Fva6.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(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 false;
|
||||
}
|
||||
}
|
59
.config/Code/User/History/3ebedc2c/GUdx.java
Normal file
59
.config/Code/User/History/3ebedc2c/GUdx.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
HttpResponse<Boolean> = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
47
.config/Code/User/History/3ebedc2c/GVrh.java
Normal file
47
.config/Code/User/History/3ebedc2c/GVrh.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString("a"));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
102
.config/Code/User/History/3ebedc2c/H8aV.java
Normal file
102
.config/Code/User/History/3ebedc2c/H8aV.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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> response = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
63
.config/Code/User/History/3ebedc2c/HArR.java
Normal file
63
.config/Code/User/History/3ebedc2c/HArR.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.rutils;
|
||||
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
45
.config/Code/User/History/3ebedc2c/J57g.java
Normal file
45
.config/Code/User/History/3ebedc2c/J57g.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
60
.config/Code/User/History/3ebedc2c/KrMi.java
Normal file
60
.config/Code/User/History/3ebedc2c/KrMi.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.net.URI;
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
62
.config/Code/User/History/3ebedc2c/NeNN.java
Normal file
62
.config/Code/User/History/3ebedc2c/NeNN.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.rutils;
|
||||
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
48
.config/Code/User/History/3ebedc2c/Odr2.java
Normal file
48
.config/Code/User/History/3ebedc2c/Odr2.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString("a"));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
62
.config/Code/User/History/3ebedc2c/PPJR.java
Normal file
62
.config/Code/User/History/3ebedc2c/PPJR.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
63
.config/Code/User/History/3ebedc2c/QDnG.java
Normal file
63
.config/Code/User/History/3ebedc2c/QDnG.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.rutils;
|
||||
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
e1.printStackTrace();
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
87
.config/Code/User/History/3ebedc2c/RDrx.java
Normal file
87
.config/Code/User/History/3ebedc2c/RDrx.java
Normal file
|
@ -0,0 +1,87 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
63
.config/Code/User/History/3ebedc2c/RJfw.java
Normal file
63
.config/Code/User/History/3ebedc2c/RJfw.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
64
.config/Code/User/History/3ebedc2c/Ricx.java
Normal file
64
.config/Code/User/History/3ebedc2c/Ricx.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
63
.config/Code/User/History/3ebedc2c/SMZB.java
Normal file
63
.config/Code/User/History/3ebedc2c/SMZB.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
72
.config/Code/User/History/3ebedc2c/STLi.java
Normal file
72
.config/Code/User/History/3ebedc2c/STLi.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
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 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(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 false;
|
||||
}
|
||||
}
|
62
.config/Code/User/History/3ebedc2c/T4I0.java
Normal file
62
.config/Code/User/History/3ebedc2c/T4I0.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
try{
|
||||
// String jsonPayload = String.format("", null)
|
||||
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
60
.config/Code/User/History/3ebedc2c/Uy0X.java
Normal file
60
.config/Code/User/History/3ebedc2c/Uy0X.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.net.URI;
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
102
.config/Code/User/History/3ebedc2c/VLHJ.java
Normal file
102
.config/Code/User/History/3ebedc2c/VLHJ.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
72
.config/Code/User/History/3ebedc2c/XIPI.java
Normal file
72
.config/Code/User/History/3ebedc2c/XIPI.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
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 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;
|
||||
}
|
||||
}
|
65
.config/Code/User/History/3ebedc2c/XXke.java
Normal file
65
.config/Code/User/History/3ebedc2c/XXke.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
50
.config/Code/User/History/3ebedc2c/Xco7.java
Normal file
50
.config/Code/User/History/3ebedc2c/Xco7.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
70
.config/Code/User/History/3ebedc2c/Z3VO.java
Normal file
70
.config/Code/User/History/3ebedc2c/Z3VO.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.rutils;
|
||||
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(URISyntaxException e1){
|
||||
e1.printStackTrace();
|
||||
System.err.println("Invalid Uri provided for http request");
|
||||
}
|
||||
catch(InterruptedException e2){
|
||||
e2.printStackTrace();
|
||||
System.err.println("");
|
||||
}
|
||||
catch(IOException e3){
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
86
.config/Code/User/History/3ebedc2c/br1k.java
Normal file
86
.config/Code/User/History/3ebedc2c/br1k.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
String jsonPayload = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", username, password);
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost:8000/register"))
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
58
.config/Code/User/History/3ebedc2c/csFf.java
Normal file
58
.config/Code/User/History/3ebedc2c/csFf.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
1
.config/Code/User/History/3ebedc2c/entries.json
Normal file
1
.config/Code/User/History/3ebedc2c/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/Java/HCloud/hcloudclient/src/main/java/com/rutils/HttpsUtil.java","entries":[{"id":"DqWf.java","timestamp":1720432959452},{"id":"CM6G.java","timestamp":1720432994332},{"id":"io8E.java","timestamp":1720433006193},{"id":"J57g.java","timestamp":1720433079624},{"id":"igxT.java","timestamp":1720433152672},{"id":"GVrh.java","timestamp":1720433170455},{"id":"Odr2.java","source":"Import 'BodyPublishers' (java.net.http.HttpRequest)","timestamp":1720433174885},{"id":"Xco7.java","timestamp":1720433205383},{"id":"qkDj.java","timestamp":1720433232593},{"id":"csFf.java","timestamp":1720433244220},{"id":"GUdx.java","timestamp":1720433292358},{"id":"T4I0.java","timestamp":1720433672172},{"id":"v5Z6.java","timestamp":1720433821392},{"id":"rEP1.java","timestamp":1720433858433},{"id":"SMZB.java","timestamp":1720433894050},{"id":"Ricx.java","timestamp":1720434016893},{"id":"XXke.java","timestamp":1720434048887},{"id":"45ez.java","timestamp":1720434150839},{"id":"yYJw.java","timestamp":1720434162465},{"id":"9k3R.java","timestamp":1720434175541},{"id":"RJfw.java","timestamp":1720434204402},{"id":"PPJR.java","timestamp":1720434592392},{"id":"prlc.java","source":"Remove all unused imports","timestamp":1720434714536},{"id":"Uy0X.java","timestamp":1720434929286},{"id":"vEWs.java","timestamp":1720763406992},{"id":"KrMi.java","timestamp":1720763522854},{"id":"1FUH.java","source":"Import 'URISyntaxException' (java.net)","timestamp":1720763528500},{"id":"NeNN.java","timestamp":1720763538884},{"id":"HArR.java","timestamp":1720763549681},{"id":"QDnG.java","timestamp":1720763645922},{"id":"Z3VO.java","timestamp":1720763695010},{"id":"Frfy.java","timestamp":1720763745010},{"id":"Fva6.java","timestamp":1720763782191},{"id":"STLi.java","timestamp":1720764055475},{"id":"mXhJ.java","timestamp":1720774859879},{"id":"XIPI.java","timestamp":1720774872732},{"id":"revA.java","timestamp":1720775296810},{"id":"7xBM.java","timestamp":1720775321788},{"id":"br1k.java","timestamp":1720775427608},{"id":"RDrx.java","timestamp":1720775456404},{"id":"q83R.java","timestamp":1720775471480},{"id":"Dr2z.java","timestamp":1720775499192},{"id":"0RVB.java","timestamp":1720775516982},{"id":"H8aV.java","timestamp":1720775539908},{"id":"3XuQ.java","timestamp":1720775615539},{"id":"VLHJ.java","timestamp":1720775632563},{"id":"EeZu.java","timestamp":1720775663822},{"id":"xQlu.java","timestamp":1720775812705},{"id":"v8Hy.java","timestamp":1720777989099},{"id":"jLq7.java","timestamp":1720781781688}]}
|
47
.config/Code/User/History/3ebedc2c/igxT.java
Normal file
47
.config/Code/User/History/3ebedc2c/igxT.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri("https://localhost/login")
|
||||
.POST(BodyPublishers.ofString("a"));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
48
.config/Code/User/History/3ebedc2c/io8E.java
Normal file
48
.config/Code/User/History/3ebedc2c/io8E.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
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 void sendHttpsReq(HttpRequest request){
|
||||
try{
|
||||
client.send(request, BodyHandlers.ofString());
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
101
.config/Code/User/History/3ebedc2c/jLq7.java
Normal file
101
.config/Code/User/History/3ebedc2c/jLq7.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;
|
||||
}
|
||||
}
|
72
.config/Code/User/History/3ebedc2c/mXhJ.java
Normal file
72
.config/Code/User/History/3ebedc2c/mXhJ.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
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 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 response;
|
||||
}
|
||||
}
|
60
.config/Code/User/History/3ebedc2c/prlc.java
Normal file
60
.config/Code/User/History/3ebedc2c/prlc.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.net.URI;
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
92
.config/Code/User/History/3ebedc2c/q83R.java
Normal file
92
.config/Code/User/History/3ebedc2c/q83R.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
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 != passwordAgain) return 0;
|
||||
else{
|
||||
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();
|
||||
}
|
||||
catch(URISyntaxException 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;
|
||||
}
|
||||
}
|
56
.config/Code/User/History/3ebedc2c/qkDj.java
Normal file
56
.config/Code/User/History/3ebedc2c/qkDj.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
try{
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
62
.config/Code/User/History/3ebedc2c/rEP1.java
Normal file
62
.config/Code/User/History/3ebedc2c/rEP1.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
78
.config/Code/User/History/3ebedc2c/revA.java
Normal file
78
.config/Code/User/History/3ebedc2c/revA.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
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){
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
62
.config/Code/User/History/3ebedc2c/v5Z6.java
Normal file
62
.config/Code/User/History/3ebedc2c/v5Z6.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean verifyCredentials(String username, String password){
|
||||
try{
|
||||
// String jsonPayload = String.format("", null)
|
||||
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI("https://localhost/login"))
|
||||
.POST(BodyPublishers.ofString(password))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
101
.config/Code/User/History/3ebedc2c/v8Hy.java
Normal file
101
.config/Code/User/History/3ebedc2c/v8Hy.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)){
|
||||
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;
|
||||
}
|
||||
}
|
56
.config/Code/User/History/3ebedc2c/vEWs.java
Normal file
56
.config/Code/User/History/3ebedc2c/vEWs.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.net.URI;
|
||||
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 boolean 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());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse.body());
|
||||
return response;
|
||||
// }
|
||||
|
||||
}
|
103
.config/Code/User/History/3ebedc2c/xQlu.java
Normal file
103
.config/Code/User/History/3ebedc2c/xQlu.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
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)) return 0;
|
||||
else{
|
||||
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;
|
||||
}
|
||||
}
|
66
.config/Code/User/History/3ebedc2c/yYJw.java
Normal file
66
.config/Code/User/History/3ebedc2c/yYJw.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.rutils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpRequest.BodyPublisher;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.security.KeyStore;
|
||||
import org.json.JSONObject;
|
||||
|
||||
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 boolean 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/login"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(BodyPublishers.ofString(jsonPayload))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> httpResponse = client.send(request, BodyHandlers.ofString());
|
||||
|
||||
boolean response = Boolean.parseBoolean(httpResponse);
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue