1 3 package com.sslexplorer.extensions.types; 4 5 import java.io.IOException ; 6 import java.util.Iterator ; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 import org.jdom.Element; 11 12 import com.sslexplorer.agent.AgentExtensionDefinition; 13 import com.sslexplorer.boot.Util; 14 import com.sslexplorer.extensions.ExtensionDescriptor; 15 import com.sslexplorer.extensions.ExtensionException; 16 import com.sslexplorer.extensions.ExtensionType; 17 import com.sslexplorer.security.SessionInfo; 18 19 24 public class AgentType implements ExtensionType { 25 26 final static Log log = LogFactory.getLog(AgentType.class); 27 28 31 public final static String TYPE = "agent"; 32 33 35 private AgentExtensionDefinition def; 36 37 43 public void start(ExtensionDescriptor descriptor, Element element) throws ExtensionException { 44 45 if (element.getName().equals(TYPE)) { 46 String className = element.getAttributeValue("class"); 48 String plugin = element.getAttributeValue("plugin"); 49 Element xml = (Element) element.clone(); 50 def = new AgentExtensionDefinition(descriptor, className, plugin, xml); 51 for (Iterator i = xml.getChildren().iterator(); i.hasNext();) { 52 processElement((Element) i.next(), descriptor); 53 } 54 55 58 DefaultAgentType.addAgentExtension(def); 59 } 60 } 61 62 private void processElement(Element xml, ExtensionDescriptor descriptor) throws ExtensionException { 63 64 for (Iterator i = xml.getChildren().iterator(); i.hasNext();) { 65 Element el = (Element) i.next(); 66 if (el.getName().equals("classpath")) { 67 processElement(el, descriptor); 68 } else if(el.getName().equals("if")) { 69 processElement(el, descriptor); 70 } else if(el.getName().equals("file")) { 71 descriptor.processFile(el); 72 } else if(el.getName().equals("jar")) { 73 descriptor.processFile(el); 74 } 75 76 } 77 } 78 79 84 public void verifyRequiredElements() throws ExtensionException { 85 86 } 87 88 93 public boolean isHidden() { 94 return true; 95 } 96 97 102 public String getType() { 103 return TYPE; 104 } 105 106 111 public void stop() throws ExtensionException { 112 if (def != null) { 113 DefaultAgentType.removeAgentExtension(def); 114 } 115 } 116 117 122 public void activate() throws ExtensionException { 123 } 124 125 130 public boolean canStop() throws ExtensionException { 131 return false; 132 } 133 134 137 public void descriptorCreated(Element element, SessionInfo session) throws IOException { 138 } 139 140 143 public String getTypeBundle() { 144 return "extensions"; 145 } 146 } | Popular Tags |