content: package code.inspector.form.module;
  
  import code.inspector.core.Const;
  import com.intellij.uiDesigner.core.GridConstraints;
  import com.intellij.uiDesigner.core.GridLayoutManager;
  
  import javax.swing.*;
  import javax.swing.border.TitledBorder;
  import javax.swing.plaf.FontUIResource;
  import javax.swing.text.StyleContext;
  import java.awt.*;
  import java.util.HashMap;
  import java.util.Locale;
  
  public class SSRFModule {
      public JPanel parentPanel;
      private JCheckBox httpUrlConnectionCheckBox;
      private JTextArea httpUrlConnectionArea;
      private JCheckBox apacheHttpClientCheckBox;
      private JTextArea apacheHttpArea;
      private JCheckBox newSocketCheckBox;
      private JTextArea socketArea;
      private JCheckBox okhttpClientCheckBox;
      private JTextArea okhttpClientArea;
      private JButton saveConfigButton;
  
      public SSRFModule(HashMap<String, Boolean> option) {
          httpUrlConnectionCheckBox.setSelected(option.getOrDefault(
                  Const.SSRF_JDK_TYPE, false));
          apacheHttpClientCheckBox.setSelected(option.getOrDefault(
                  Const.SSRF_APACHE_TYPE, false));
          newSocketCheckBox.setSelected(option.getOrDefault(
                  Const.SSRF_SOCKET_TYPE, false));
          okhttpClientCheckBox.setSelected(option.getOrDefault(
                  Const.SSRF_OKHTTP_TYPE, false));
          saveConfigButton.addActionListener(e -> {
              option.put(Const.SSRF_JDK_TYPE, httpUrlConnectionCheckBox.isSelected());
              option.put(Const.SSRF_APACHE_TYPE, apacheHttpClientCheckBox.isSelected());
              option.put(Const.SSRF_SOCKET_TYPE, newSocketCheckBox.isSelected());
              option.put(Const.SSRF_OKHTTP_TYPE, okhttpClientCheckBox.isSelected());
              JOptionPane.showMessageDialog(parentPanel, "success!");
          });
      }
  
      {
  // GUI initializer generated by IntelliJ IDEA GUI Designer
  // >>> IMPORTANT!! <<<
  // DO NOT EDIT OR ADD ANY CODE HERE!
          $$$setupUI$$$();
      }
  
      /**
       * Method generated by IntelliJ IDEA GUI Designer
       * >>> IMPORTANT!! <<<
       * DO NOT edit this method OR call it in your code!
       *
       * @noinspection ALL
       */
      private void $$$setupUI$$$() {
          parentPanel = new JPanel();
          parentPanel.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1));
          parentPanel.setBorder(BorderFactory.createTitledBorder(null, "SSRF Module", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
          httpUrlConnectionCheckBox = new JCheckBox();
          httpUrlConnectionCheckBox.setText("http url connection");
          parentPanel.add(httpUrlConnectionCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          httpUrlConnectionArea = new JTextArea();
          httpUrlConnectionArea.setEditable(false);
          Font httpUrlConnectionAreaFont = this.$$$getFont$$$("Consolas", -1, 12, httpUrlConnectionArea.getFont());
          if (httpUrlConnectionAreaFont != null) httpUrlConnectionArea.setFont(httpUrlConnectionAreaFont);
          httpUrlConnectionArea.setForeground(new Color(-9097));
          httpUrlConnectionArea.setText("URL url = new URL(input);\nHttpURLConnection con = (HttpURLConnection) url.openConnection();\ncon.getInputStream();");
          parentPanel.add(httpUrlConnectionArea, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          apacheHttpClientCheckBox = new JCheckBox();
          apacheHttpClientCheckBox.setText("apache http client");
          parentPanel.add(apacheHttpClientCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          apacheHttpArea = new JTextArea();
          apacheHttpArea.setEditable(false);
          Font apacheHttpAreaFont = this.$$$getFont$$$("Consolas", -1, 12, apacheHttpArea.getFont());
          if (apacheHttpAreaFont != null) apacheHttpArea.setFont(apacheHttpAreaFont);
          apacheHttpArea.setForeground(new Color(-9097));
          apacheHttpArea.setText("CloseableHttpClient httpClient = HttpClients.createDefault();\nHttpGet getRequest = new HttpGet(input);\nHttpResponse response = httpClient.execute(getRequest);");
          parentPanel.add(apacheHttpArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          newSocketCheckBox = new JCheckBox();
          newSocketCheckBox.setText("new socket");
          parentPanel.add(newSocketCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          socketArea = new JTextArea();
          socketArea.setEditable(false);
          Font socketAreaFont = this.$$$getFont$$$("Consolas", -1, 12, socketArea.getFont());
          if (socketAreaFont != null) socketArea.setFont(socketAreaFont);
          socketArea.setForeground(new Color(-9097));
          socketArea.setText("Socket socket = new Socket(host, port);\nInputStream in = socket.getInputStream();");
          parentPanel.add(socketArea, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          okhttpClientCheckBox = new JCheckBox();
          okhttpClientCheckBox.setText("okhttp client");
          parentPanel.add(okhttpClientCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          okhttpClientArea = new JTextArea();
          okhttpClientArea.setEditable(false);
          Font okhttpClientAreaFont = this.$$$getFont$$$("Consolas", -1, 12, okhttpClientArea.getFont());
          if (okhttpClientAreaFont != null) okhttpClientArea.setFont(okhttpClientAreaFont);
          okhttpClientArea.setForeground(new Color(-9097));
          okhttpClientArea.setText("OkHttpClient httpClient = new OkHttpClient();\nRequest request = new Request.Builder()\n                    .url(input)\n                    .build();\nResponse response = httpClient.newCall(request).execute();");
          parentPanel.add(okhttpClientArea, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          saveConfigButton = new JButton();
          saveConfigButton.setText("Save Config");
          parentPanel.add(saveConfigButton, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
      }
  
      /**
       * @noinspection ALL
       */
      private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
          if (currentFont == null) return null;
          String resultName;
          if (fontName == null) {
              resultName = currentFont.getName();
          } else {
              Font testFont = new Font(fontName, Font.PLAIN, 10);
              if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
                  resultName = fontName;
              } else {
                  resultName = currentFont.getName();
              }
          }
          Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
          boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
          Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
          return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
      }
  
      /**
       * @noinspection ALL
       */
      public JComponent $$$getRootComponent$$$() {
          return parentPanel;
      }
  }
  