⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parametertransformation.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
package com.sslexplorer.vpn.util;

import java.io.IOException;
import java.io.File;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;

public class ParameterTransformation {

  XMLElement el;
  ApplicationLauncher launcher;
  Transformation trans;
  String outputParam;
  String inputParam;

  ParameterTransformation(XMLElement el, ApplicationLauncher launcher) throws IOException {

    if(el.getAttribute("class")==null ||
        el.getAttribute("input") == null ||
         el.getAttribute("output") == null)
          throw new IOException("<transform> element requires class, input and output attributes!");

    this.el = el;
    this.launcher = launcher;


  }

  public void processTransformation() throws IOException {

    String classFile = el.getAttribute("class").toString();
    inputParam = el.getAttribute("input").toString();
    outputParam = el.getAttribute("output").toString();

    File f = new File(launcher.getInstallDir(), classFile + ".class");

    if(!f.exists())
      throw new IOException(classFile + " does not exist! Did you forget to place the .class file in a <file> element?");

    FileInputStream in = new FileInputStream(f);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    byte[] buf = new byte[16384];
    int read;

    while((read = in.read(buf)) > -1) {
      out.write(buf, 0, read);
    }

    in.close();
    buf = out.toByteArray();
    try {

      launcher.events.debug("Loading transformation class " + classFile);
      Class cls = ByteArrayClassLoader.getInstance().createFromByteArray(
          classFile, buf, 0, buf.length);

      launcher.events.debug("Creating transformation instance");
      Transformation t = (Transformation) cls.newInstance();

      launcher.events.debug("Invoking transformation");
      launcher.addParameter(outputParam, t.transform(launcher.replaceTokens(inputParam)));
    }
    catch (Exception ex) {
      launcher.events.debug("Exception in Transformation class: " + ex.getMessage());
    }

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -