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

📄 agenttype.java

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

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Element;
import org.jdom.JDOMException;

import com.sslexplorer.agent.AgentExtensionDefinition;
import com.sslexplorer.extensions.ExtensionDescriptor;
import com.sslexplorer.extensions.ExtensionType;
import com.sslexplorer.extensions.store.ExtensionStore;

public class AgentType implements ExtensionType {

    final static Log log = LogFactory.getLog(AgentType.class);
    
    final static String TYPE = "agent";

    public void load(ExtensionDescriptor descriptor, Element element) throws JDOMException, IOException {

        if(element.getName().equals(TYPE)) {

                  // Agent classname
                  String className = element.getAttributeValue("class");
                  String plugin = element.getAttributeValue("plugin");
                  
                  if(className == null || className.equals("")) {
                      throw new JDOMException("The class attribute must be supplied for <agent> elements.");
                  }

                  AgentExtensionDefinition def = new AgentExtensionDefinition(descriptor, className, plugin);


                  for(Iterator i  = element.getChildren().iterator(); i.hasNext(); ) {
                      Element el = (Element)i.next();
                      if(el.getName().equals("classpath")) {
                    	  
                    	  for(Iterator i2 = el.getChildren().iterator(); i2.hasNext();) {
                    		  
                    		  Element child = (Element) i2.next();
                    		  
                    		  if(child.getName().equals("jar")) {
		                          String path = child.getText();
		                          if(path != null && !path.equals("")) {
		                              File f = new File(descriptor.getApplicationBundle().getBaseDir(),
		                                              path);
		                              if(f.exists()) {
		                                  def.addClassPath(path);
		                                  descriptor.processFile(child);
		                              }
		                              else {
		                                  log.warn("Agent <jar> element " + f.getAbsolutePath() + " does not exist.");
		                              }
		                          }
                    		  } else
                    			  log.warn("Unknown element <" + child.getName() + "> in <classpath>");
                    	  }
                      } else if(el.getName().equals("jvm")) {
                    	 def.addJVMArgument(el.getText());
                      } else {
                          throw new JDOMException("The <agent> element only supports the nested <classpath> elements");
                      }
                  }

                  /**
                   * Notify the extension store of a new agent plugin
                   */
                  ExtensionStore.getInstance().addAgentExtension(def);
                  
        }


      }

      public void verifyRequiredElements() throws JDOMException {

      }    
      
      public boolean isHidden() {
          return true;
      }
      
      public String getType() {
          return TYPE;
      }  
}

⌨️ 快捷键说明

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