2023-02-22 21:53:10 +01:00

89 lines
2.7 KiB
Java

package xyz.thastertyn;
import xyz.thastertyn.Jecna.*;
import xyz.thastertyn.Window.MainWindow;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
//System.out.println("Hello World!");
//Login l = new Login();
//l.login(Credentials.user, Credentials.pass);
MainWindow window = new MainWindow();
window.run();
/*
try {
//#region Jidelna
//#region JSESSIONID
Connection.Response jidelna = Jsoup.connect("https://objednavky.jidelnasokolska.cz/")
.header("Connection", "keep-alive")
.method(Method.HEAD)
.execute();
String jidelnaJSESSIONID = jidelna.cookie("JSESSIONID");
String XSRF_TOKEN = jidelna.cookie("XSRF-TOKEN");
//#endregion
//#region CSRF
String csrf = Jsoup.connect("https://objednavky.jidelnasokolska.cz/faces/login.jsp")
.header("Connection", "keep-alive")
.cookie("XSRF-TOKEN", XSRF_TOKEN)
.cookie("JSESSIONID", jidelnaJSESSIONID)
.get()
.select("input[name=_csrf]")
.attr("value");
if(!XSRF_TOKEN.equals(csrf))
{
throw new SecurityException("CSRF tokens do not match, something is up");
}
//#endregion
//#region Login
Connection.Response jidelnaLogin = Jsoup.connect("https://objednavky.jidelnasokolska.cz/j_spring_security_check")
.header("Connection", "keep-alive")
.header("Content-Type", "application/x-www-form-urlencoded")
.cookie("XSRF-TOKEN", XSRF_TOKEN)
.cookie("JSESSIONID", jidelnaJSESSIONID)
.data("j_username", Credentials.user)
.data("j_password", Credentials.pass)
.data("terminal", "false")
.data("type", "web")
.data("_csrf", XSRF_TOKEN)
.data("targetUrl", "/faces/secured/main.jsp?terminal=false&status=true&printer=false&keyboard=false")
.method(Method.POST)
.execute();
//#endregion
Document obedy = Jsoup.connect("https://objednavky.jidelnasokolska.cz/faces/secured/month.jsp?terminal=false&keyboard=&printer=")
.header("Connection", "keep-alive")
.cookie("XSRF-TOKEN", XSRF_TOKEN)
.cookie("JSESSIONID", jidelnaJSESSIONID)
.get();
System.out.println(obedy.toString());
//#endregion
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e)
{
e.printStackTrace();
}*/
}
}